Skip to content

Instantly share code, notes, and snippets.

@hajipy
Created March 29, 2019 13:40
Show Gist options
  • Save hajipy/280d22320c598f2667235b9ec7df0e24 to your computer and use it in GitHub Desktop.
Save hajipy/280d22320c598f2667235b9ec7df0e24 to your computer and use it in GitHub Desktop.
Nested Promise
// Promise chain Style
const aPromise = Promise.resolve(1).then(result => Promise.resolve(result));
// Promise.then Style
// const aPromise = new Promise((resolve) => Promise.resolve(1).then((result) => resolve(result)));
// async/await Style
// const aPromise = new Promise(async (resolve) => resolve(await Promise.resolve(1)));
aPromise.then(
(result) => console.log(result)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment