There are two scenarios in my case.
In the first case the code is working fine.
Why is it throwing an error in this case. Can't I use await in then
or is there a problem with using try catch inside the then
statement?
I should also mention that the platform that I am coding in is a little different but it accepts pure JavaScript too.
Await will already resolve your promise, so "then" wont be having any promise to resolve.
For await async try this
private myMethod = async () => {
try {
const response = await yourPromise();
} catch (e) {
console.error(e)
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.