Skip to content

Instantly share code, notes, and snippets.

@gthrm
Created September 22, 2019 11:17
Show Gist options
  • Save gthrm/97391d89262c362e4076c6486f7ffd29 to your computer and use it in GitHub Desktop.
Save gthrm/97391d89262c362e4076c6486f7ffd29 to your computer and use it in GitHub Desktop.
async await function
async function sendCASH() {
let promise = new Promise((resolve, reject) => {
setTimeout(() => resolve('Ok, nice!'), 3000);
setTimeout(() => reject('Fuck, shit!'), 4000); //не сработает
});
let result = await promise;
return result;
}
sendCASH()
.then(result => console.warn(result))
.catch(err => console.error(err))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment