修复 Promise 'TypeError: myfunc(...).then(...).reject is not a function'

当在 Javascript 中遇到与 Promise 相关的此错误消息:

promise_typeerror_output.txt
TypeError: myfunc(...).then(...).reject is not a function

解决方案非常简单:当你想捕获 promise 的错误时,你需要使用 catch 而不是 reject,如下所示:

promise_fix.js
myfunc(...).then(...).catch(...)

Check out similar posts by category: Javascript