我遇到了一个无法调试的特殊问题。 TypeError:我的代码返回函数未定义,这结束了 API 调用,但我查看了日志和断点,在 API 以错误结束后,它继续执行相同的 then 函数。
这怎么可能。
我正在使用nodejs/express/sequelizejs
models.Holdings.update(obj,{
where:{
id: obj.id
}
}).then().catch()
最佳答案
Then 和 catch 旨在提供在解析和错误时执行的函数(分别)。
models.Holdings.update(obj,{
where:{
id: obj.id
}
}).then(function(result) {
console.log(result);
}).catch(function(error) {
console.log(error);
});
关于javascript - Nodejs 运行 Promise 但仍然 Undefine 不是一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38837269/