I’ve tried wrapping the Validated Method .call
in a promise which lets me move away from callback syntax but it looks like I don’t receive the stub value in the client anymore. Is there a way to use promises and return the stub value?
// callbacks syntax - works as expected
function submit() {
// todoId is available immediately from stub value
const todoId = insert.call({text: newTodo}, error => {
return alert(error)
});
}
// wrapping the Validated Method in a promise and using async / await syntax
// this works but I don't get the stub value
// if I don't wrap Validated Method in a promise, I get the stub value but the error doesn't appear to be caught in the catch block
async function submit() {
try {
const todoId = await insert.call({text: newTodo}) // no stub value, only get todoId after server has returned
console.log('todoId', todoId);
} catch (error) {
return alert(error)
}