0
点赞
收藏
分享

微信扫一扫

Node.js报错:UnhandledPromiseRejectionWarning: Unhandled promise rejection

钵仔糕的波波仔 2022-03-15 阅读 36


UnhandledPromiseRejectionWarning: Unhandled promise rejection. 
This error originated either by throwing inside of an async function without a catch block,
or by rejecting a promise which was not handled with .catch()

解决办法: 增加catch

new Promise((resolve, reject)=>{
if(2>1) reject("foo")
resolve("bar")
}).catch(()=>{})


参考
Promise的UnhandledPromiseRejectionWarning问题




举报

相关推荐

0 条评论