Skip to content

Instantly share code, notes, and snippets.

@sabarasaba
Created Jul 16, 2013
Embed
What would you like to do?
currying
var o = '{ "user": "tu vieja", "posts": [ { "title": "title 1", "contents": "..." }, { "title": "title 2", "contents": "..." } ] }';
var fetchShit = function() {
var def = $.Deferred();
setTimeout(function() {
def.resolve(o);
}, 2000);
return def.promise();
};
fetchShit()
.then(JSON.parse)
.then(function(data){ return data.posts })
.then(function(posts){
return posts.map(function(post){ return post.title })
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment