Skip to content

Instantly share code, notes, and snippets.

@mulderp mulderp/gist:7045228
Created Oct 18, 2013

Embed
What would you like to do?
nested promises
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);
});
@agatsoh

This comment has been minimized.

Copy link

commented Feb 9, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.