Search code examples
javascriptpromisebluebird

How to construct a Bluebird promise that returns a constant string?


If I have something like this

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
    }
  });

How do I do something like

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

Solution

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

    or

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