Skip to content

Instantly share code, notes, and snippets.

@malikperang
Created August 2, 2021 17:36
Show Gist options
  • Save malikperang/85d7ab0c617ed156bda6c7eed9aea9cc to your computer and use it in GitHub Desktop.
Save malikperang/85d7ab0c617ed156bda6c7eed9aea9cc to your computer and use it in GitHub Desktop.
JS promise
function abc() {
var promise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('step 1');
}, 1000);
});
return promise;
}
async function def(){
await abc().then((data) => {
console.log(data);
console.log('step 2');
})
}
def();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment