Javascript 承诺已创建但未从中返回

Javascript 承诺已创建但未从中返回,javascript,node.js,promise,bookshelf.js,Javascript,Node.js,Promise,Bookshelf.js,我正试着把我的头绕在这上面。。。但不管我把它放在哪里,我都会得到这个警告 警告:在home/app/server/node_modules/express/lib/router/index.js:280:7的处理程序中创建了承诺,但未从中返回 服务器| at._doFetch(/home/app/server/node_modules/bluebird/js/release/method.js:13:13) 我正在使用Bookshelf.js,我应该在这里返回什么?您必须从导出的方法返回承诺,这

我正试着把我的头绕在这上面。。。但不管我把它放在哪里,我都会得到这个警告

警告:在home/app/server/node_modules/express/lib/router/index.js:280:7的处理程序中创建了承诺,但未从中返回 服务器| at._doFetch(/home/app/server/node_modules/bluebird/js/release/method.js:13:13)


我正在使用Bookshelf.js,我应该在这里返回什么?

您必须从导出的方法返回承诺,这样承诺就可以在外部处理。试着把它改成

module.exports = {
  getUser: (req, res) => {
    var found_user = User.query({where: {email: req.body.email}, orWhere: {username: req.body.email}}).fetch()

    found_user.then(user => {
      if (user) {
        res.status(200).json(user)
      } else {
        res.status(422).json(new error.ERROR_422("No user found under username/email"));
      }
    })
    .catch(err => {
        console.log(err)
        res.status(500).json(new error.ERROR_500(err));
    })

    return found_user // <<<--- Add this
  }
module.exports={
getUser:(请求、回复)=>{
var found_user=user.query({where:{email:req.body.email},或where:{username:req.body.email})。fetch()
找到用户。然后(用户=>{
如果(用户){
res.status(200).json(用户)
}否则{
res.status(422.json)(新错误。错误_422(“用户名/电子邮件下找不到用户”);
}
})
.catch(错误=>{
console.log(错误)
res.status(500).json(新错误.error_500(err));
})

return found\u user//尝试使用
return found\u user。然后…
是什么给你带来了错误?我向你保证,你在这里所做的一切都没有错。可能是因为某个地方有一个过于热心的eslint文件吗?@GeorgeMauer这就是为什么我感到沮丧的原因,我的意思是,它们都是警告而不是错误,代码运行良好,只是我正在访问的地方g这是正确的,那么您在哪里和什么时候看到的?在运行时在控制台中?在保存文件时在文本编辑器中?在构建过程中?我们的开发环境中有一些东西正在这样做,但不幸的是,我们无法猜测。可能使用
Promise.resolve();
module.exports = {
  getUser: (req, res) => {
    var found_user = User.query({where: {email: req.body.email}, orWhere: {username: req.body.email}}).fetch()

    found_user.then(user => {
      if (user) {
        res.status(200).json(user)
      } else {
        res.status(422).json(new error.ERROR_422("No user found under username/email"));
      }
    })
    .catch(err => {
        console.log(err)
        res.status(500).json(new error.ERROR_500(err));
    })

    return found_user // <<<--- Add this
  }