如何构造一个返回常量字符串的Bluebird Promise? [英] How to construct a Bluebird promise that returns a constant string?

查看:42
本文介绍了如何构造一个返回常量字符串的Bluebird Promise?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有这样的东西

return this.retrieveArticles(blogId).then(function(response){
    return response.articles;
  }).then(_).call("findWhere", match).then(function(article){
    return {
      "article": article
    }
  });

然后我决定将最上面的部分砍掉

and I decide to chop the top bit off

    return response.articles;
  }).then(_).call("findWhere", match).then(function(article){
    return {
      "article": article
    }
  });

我该怎么做

Promise.return(articles).then(_).call("findWhere", match).then(function(article){
    return {
      "article": article
    }
  });

推荐答案

Promise.resolve(_(articles)).call("findWhere", match);

Promise.resolve(articles).then(_).call("findWhere", match);

这篇关于如何构造一个返回常量字符串的Bluebird Promise?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆