Skip to content

Instantly share code, notes, and snippets.

@smockle
Created December 18, 2014 23:18
Show Gist options
  • Save smockle/3f6fa478c82a4b734940 to your computer and use it in GitHub Desktop.
Save smockle/3f6fa478c82a4b734940 to your computer and use it in GitHub Desktop.
Chaining promises in JavaScript.
get("/api/google/sheets/resources")
.then(JSON.parse)
.then(function (context) {
return handlebar("#template", "#output", context);
})
.then(function (context) {
return pourover(context);
})
.then(function (view) {
return linkify(view);
})
.catch(function(err) {
console.error(err);
});
@getify
Copy link

getify commented Jan 13, 2015

@KidkArolis

catch(console.error)

That doesn't work, since error(..) loses its context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment