Javascript - 无法解决此问题 'warning: promise was created in a handler'
Javascript - can't resolve this 'warning: promise was created in a handler'
在 nodejs 应用程序中使用 sequelize.js,我有一个 promise.all
接受两个承诺(一个 user
查询和一个 color
查询):
router.get(`/someEndPoint`, (req, res) => {
let userAccount = user.findOne({
where: {
id: //some ID
}
});
let colorStuff = color.findOne({
where: {
colorName: //some color
}
})
Promise.all([userAccount , colorStuff ]).then(([result1, result2]) => {
//do stuff, such as:
res.send('success');
}).catch(err => {
console.log(err)
});
});
在说 //do stuff
的部分,我的控制台一直给我这个警告:
a promise was created in a handler at... but was not returned from it,
see (URL that I can't post) at Function.Promise.attempt.Promise.try
我不确定如何解决这个问题。我在 .then
之后认为承诺已解决?
如果没有其他上下文很难判断,但也许您需要 return Promise.all
return Promise.all([user, color])...
如果在 // do stuff 区域中创建了任何其他承诺,请务必 return 也创建这些承诺。
在 nodejs 应用程序中使用 sequelize.js,我有一个 promise.all
接受两个承诺(一个 user
查询和一个 color
查询):
router.get(`/someEndPoint`, (req, res) => {
let userAccount = user.findOne({
where: {
id: //some ID
}
});
let colorStuff = color.findOne({
where: {
colorName: //some color
}
})
Promise.all([userAccount , colorStuff ]).then(([result1, result2]) => {
//do stuff, such as:
res.send('success');
}).catch(err => {
console.log(err)
});
});
在说 //do stuff
的部分,我的控制台一直给我这个警告:
a promise was created in a handler at... but was not returned from it,
see (URL that I can't post) at Function.Promise.attempt.Promise.try
我不确定如何解决这个问题。我在 .then
之后认为承诺已解决?
如果没有其他上下文很难判断,但也许您需要 return Promise.all
return Promise.all([user, color])...
如果在 // do stuff 区域中创建了任何其他承诺,请务必 return 也创建这些承诺。