Sometime cannot use await function in a callback, use promise chain will be ok
var process1 = ()=>{
try{
promise;
}catch(error){
console.log(error);
}
}
var process2 = ()=>{
promise.then().catch(error=>console.log(error));
}
var promise = new Promise((r,j)=>{
setTimeout(()=>{
j('rejected');
},300)
})
process1();
process2();
网友评论