I have LWCA that calls a method in LWCB (service LWC) that makes an imperative call to an APEX method. The problem is that the promise is not behaving as expected.
LWCA
import serviceLWC from 'c/servicelwc';
handleButtonClick() {
this.apexCallResult = serviceLWC.callApexMethod(parm);
console.log('lwcA:' + this.apexCallResult );
}
LWCB
import verify from '@salesforce/apexContinuation/util.verify';
callApexMethod(parm) {
console.log('Service lwc');
verify ({ parm })
.then(result => {
console.log('lwcB: ' + result);
return result;
})
.catch(error => {
console.log('lwcB: ' + result);
return error;
});
},
console:
Service lwc
lwcA: undefined
lwcB: valid
I expected (maybe incorrectly) that result in lwcB would be resolved before returning the value to the calling fn (lwcA). Can you help me better understand why this isn't working as expected and how I can adjust this code to return a fulfilled promise to the caller?