node.js:req.next不是函数

时间:2017-04-30 04:13:43

标签: node.js gcloud

我已尝试将该项目部署到Google云平台。代码在我的本地计算机上运行正常。但是,我在gcloud上收到以下错误。

TypeError: req.next is not a function
at done (/app/node_modules/express/lib/response.js:955)
at tryRender (/app/node_modules/express/lib/application.js:641)
at EventEmitter.render (/app/node_modules/express/lib/application.js:591)
at ServerResponse.render (/app/node_modules/express/lib/response.js:960)
at (/app/routes/posts.js:15)
at tryCatcher (/app/node_modules/mongolass/node_modules/bluebird/js/release/util.js:16)
at Promise._settlePromiseFromHandler (/app/node_modules/mongolass/node_modules/bluebird/js/release/promise.js:510)
at Promise._settlePromise (/app/node_modules/mongolass/node_modules/bluebird/js/release/promise.js:567)
at Promise._settlePromise0 (/app/node_modules/mongolass/node_modules/bluebird/js/release/promise.js:612)
at Promise._settlePromises (/app/node_modules/mongolass/node_modules/bluebird/js/release/promise.js:691)
at Async._drainQueue (/app/node_modules/mongolass/node_modules/bluebird/js/release/async.js:138)
at Async._drainQueues (/app/node_modules/mongolass/node_modules/bluebird/js/release/async.js:148)
at Immediate.Async.drainQueues (async.js:17)
at runCallback (timers.js:666)
at tryOnImmediate (timers.js:639)
at processImmediate (timers.js:611)

路由/ posts.js:

router.get('/', function(req, res, next) {
  var author = req.query.author;

  PostModel.getPosts(author)
    .then(function (posts) {
      res.render('posts', { //line 15
        posts: posts
      });
    })
    .catch(next);
});

getPosts功能:

getPosts: function getPosts(author) {
    var query = {};
    if (author) {
      query.author = author;
    }
    return Post
      .find(query)
      .populate({ path: 'author', model: 'User' })
      .sort({ _id: -1 })
      .addCreatedAt()
      .addCommentsCount()
      .contentToHtml()
      .exec();
  },

0 个答案:

没有答案