Node.js / Sails.js 应用程序中的范围 and/or 上下文

Scope and/or context in Node.js / Sails.js application

我在 Sails.js 应用程序上 运行 这段代码,结果是一个空的 JSON。我已经阅读了几页关于范围和上下文的内容,但无法找到我做错了什么。

    var evoluciones
    HC.find({ id: req.param('id') }).then(records => {
        evoluciones = records;            
    })
    return res.json(evoluciones)

提前致谢。

@mechuda,你可以试试这个

HC.find({ id: req.param('id') })
  .then(evoluciones=> { 
       // to do something
      return [evoluciones] ; 
    })
  .spread((evoluciones ) => {
          return res.json(evoluciones )
   })
  .fail( error => {
            sails.log.error(error);
            return res.negotiate(error);
   });