Created
October 18, 2013 17:45
-
-
Save mulderp/7045228 to your computer and use it in GitHub Desktop.
nested promises
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function allMovies() { | |
return client.smembersAsync('movies.ids').then(function(ids) { | |
var movies = _.map(ids, function(id) { | |
return client.hmgetAsync("movies:" + id, 'title', 'description', 'director', 'year').then(function(data) { | |
return { | |
title: data[0], | |
description: data[1], | |
director: data[2], | |
year: data[3] | |
}; | |
}); | |
}); | |
return Promise.all(movies); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi mulderp I am new to writing Promises and hence came across your question. I want to ask you does
client.smembersAsync('movies.ids')
this function return a Promise Object or is it just a normal function. Can you call .then() on normal functions