Sorry if question label is frustrating. I am calling lwc method and do some actions on then and inside that lwc I there are apex method. But it gives me error on then inside "firstMethod". I have tried async and it didn't help
Error: Cannot read properties of undefined
firstMethod() {
this.secondMethod(true, true).then((result) => {
console.log(result);
})
}
secondMethod(boolVar1,boolVar2) {
if(boolVar2){
apexMethod({boolVar:boolVar}).then((resp)=> {
return resp;
//Promise.resolve(resp) doesnt work too
})
} else {
return Promise.resolve(true);
}
}
I have added "return apexMethod" and it works