Created
April 6, 2018 12:26
-
-
Save viniceosm/b6748ee3759f9d388fa48a9a2977bb86 to your computer and use it in GitHub Desktop.
Exemplo de promise com async function
This file contains 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
function promiseCont(cont = 0){ | |
return new Promise((resolve, reject) => { | |
resolve(cont + 1); | |
}) | |
} | |
async function contadorSincrono() { | |
try { | |
r = await promiseCont(); | |
console.log(r); | |
r = await promiseCont(r); | |
console.log(r); | |
} catch (err) { | |
console.log(err); | |
} | |
} | |
contadorSincrono(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment