why is this wrong:
markImportant({ Id: this.row.Id })
.then(this.showToast("success"))
.catch(this.showToast("error"));
And this is right?
markImportant({ Id: this.row.Id })
.then(() => {
this.showToast("success");
})
.catch(() => {
this.showToast("error");
});
I'm passing a function as a paremeter in both cases. The first case is only one function, whereas the second function is a function inside another function as a parameter.
CodePudding user response:
in .then(this.showToast("success"))
you are invoking the showToast
function which i believe it returns undefined so you can't invoke undefined
in then(() => { this.showToast("success")})
you are passing a function which can be invoked so thats why that works