Skip to content

Instantly share code, notes, and snippets.

@njofce
Created February 16, 2020 09:50
Show Gist options
  • Select an option

  • Save njofce/8419dae1fdbfbd54607cf5e616d35905 to your computer and use it in GitHub Desktop.

Select an option

Save njofce/8419dae1fdbfbd54607cf5e616d35905 to your computer and use it in GitHub Desktop.
var promise1 = new Promise((resolve, reject) => {
setTimeout(() => {
resolve(1)
}, 5000);
});
var promise2 = new Promise((resolve, reject) => {
setTimeout(() => {
resolve(2)
}, 2000);
});
promise1
.then(res => {
console.log("MESSAGE: " + res);
return promise2;
})
.then(res2 => console.log(res2))
.catch(err => console.log("ERROR: " + err));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment