Skip to content

Instantly share code, notes, and snippets.

@chinmay185
Created April 13, 2015 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chinmay185/00b76d4aebadacd4e273 to your computer and use it in GitHub Desktop.
Save chinmay185/00b76d4aebadacd4e273 to your computer and use it in GitHub Desktop.
missing return breaks the promise chain and causes subtle bugs
var q = require("q");
var getUser = function(username) {
return q.delay(500).then(function(){
return username + " user";
});
};
var getTweets = function(user) {
return q.delay(500).then(function(){
return ["tweet1", "tweet2"];
});
};
getUser("tom")
.then(function(user) {
getTweets(user)
})
.then(function(tweets) {
console.log("tweets: ", tweets);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment