Created
September 22, 2019 11:17
-
-
Save gthrm/97391d89262c362e4076c6486f7ffd29 to your computer and use it in GitHub Desktop.
async await function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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