Skip to content

Instantly share code, notes, and snippets.

@ms314006
Created January 16, 2019 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ms314006/7d20c77737b5cae67c9f5eb291f226c3 to your computer and use it in GitHub Desktop.
Save ms314006/7d20c77737b5cae67c9f5eb291f226c3 to your computer and use it in GitHub Desktop.
const lastPromise = new Promise((resolve, reject)=>{
setTimeout(()=>{resolve('last changed')},2000)
})
const newPromise = new Promise((resolve, reject)=>{
setTimeout(()=>{resolve('changed')}, 3000)
}).then((data)=>{
console.log(data)
return lastPromise.then((lastData)=>{return lastData})
}).then((data)=>{
console.log(data) // 'last changed'
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment