Skip to content

Instantly share code, notes, and snippets.

@paulbreslin
Last active May 22, 2018 22:31
Show Gist options
  • Save paulbreslin/2cbd49e98e53eafba2ab8af385646e90 to your computer and use it in GitHub Desktop.
Save paulbreslin/2cbd49e98e53eafba2ab8af385646e90 to your computer and use it in GitHub Desktop.
const example = require('example-library');
example.firstAsyncRequest()
.then( fistResponse => {
example.secondAsyncRequest(fistResponse)
.then( secondResponse => {
example.thirdAsyncRequest(secondResponse)
.then( thirdAsyncResponse => {
// Insanity continues
});
});
});
@JimiHFord
Copy link

Or even:

example.firstAsyncRequest()
  .then(firstResponse => example.secondAsyncRequest(firstResponse))
  .then(secondResponse => example.thirdAsyncRequest(secondResponse))
  .then(thirdResponse => {
     // you can keep coding with sanity :)
  });

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