I have the following db calls
const x = await doThis();
cons y = await doThat(x);
return somethingElse(x,y)
This works fine but when a promise isn't returned correctly, debugging is impossible. I want to write code something like the following
try {
const x = await doThis();
} catch (e) {
console.log(e);
}
try {
cons y = await doThat(x);
} catch (e) {
console.log(e);
}
return somethingElse(x,y);
However, I get the following error:
UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ReferenceError: x is not defined
Do the try/catch blocks stop the code from running asynchronously? How do I fix this?