我和我的朋友在node.js做项目。我们有一个错误,我们不知道它是什么。你们能解释一下吗?下面是错误:
at process._tickCallback (internal/process/next_tick.js:188:7)
(node:10758) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwin
g inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
(rejection id: 2335)
附言:我的朋友不允许我发布代码。
发布于 2019-01-27 10:16:16
当开发人员忘记通过.catch()
或try... catch
添加异步错误处理时,就会发生此错误。比较:
(async function main() {
try {
await Promise.reject();
} catch (err) {
console.error('Rejection handled.');
}
})();
Rejection handled.
(async function main() {
await Promise.reject();
})();
UnhandledPromiseRejectionWarning: ...
https://stackoverflow.com/questions/54384503
复制