关于Nodejs global var

时间:2016-10-15 02:04:18

标签: javascript node.js express

var articleFinish;
  async.series({
    one: function(callback) {
      async.eachOf(set, function(tags, index, callback) {
        Article.findById(articleId).exec(function(err, article) {
          article.weibos[2].text = 'aa'; //success
          article.weibos[2].tags = 'aaa'; //success
          article.weibos[index].text = tags; //can't set value for next 'article'
          article.weibos[index].tags = tags; //can't set value for next 'article'
          articleFinish = article;
          callback();
        });
      }, function(err) {
        if (err) console.error(err.message);
        callback(null, 3);
      });
    },
    two: function(callback) {
      Article.findById(articleId).exec(function(err, article) {
        article = articleFinish;//can't get value when use the last two statement.
        article.save(function(err) {});
      });
    }
  }, function(err, results) {
    res.send(results);
  });

我想通过全局变量

设置最后article的值

我该怎么办?

0 个答案:

没有答案
相关问题