0

I am not sure if this is just down to lwc running in strict mode, but when I call the methods below they are rejected with this error.

Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.invokeGetter

 // create promises to fetch data from server
var promise1 = new Promise($A.getCallback(function(resolve, reject) {
    helper.method1(component, helper);
    if (reject) {
        reject(reject);
    } else {
        resolve(resolve);
    }
}));


var promise2 = new Promise($A.getCallback(function(resolve, reject) {

    helper.method2(component, helper);
    if (reject) {
        reject(reject);
    } else {
        resolve(resolve);
    }
}));

Promise.all([promise1, promise2])
    .then(function(results) {
        console.log("Success: " + results);
    })
    .catch(function(error) {
        console.log("promise1: ", promise1);
        console.log("promise2: ", promise2);
});

This may not be down to strict mode, but this is just what I found online, so any help or knowledge would be appreciated.

1 Answer 1

1
if (reject) {
  reject(reject);
} else {
  resolve(resolve);
}

You're breaking the rules of how Promises work. While I haven't managed to exactly replicate your error, I can tell you the problem is that you're rejecting your own promises every time. I think you meant to write:

try {
  resolve(helper.method1(component, helper));
} catch(e) {
  reject(e);
}

And later:

Promise.all([promise1, promise2])
  .then(function(results) {
    console.log('success!', results);
  })
  .catch(function(error) {
     console.error('errors!', error);
  });

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .