Skip to content

Instantly share code, notes, and snippets.

@viniceosm
Created April 6, 2018 12:26
Show Gist options
  • Save viniceosm/b6748ee3759f9d388fa48a9a2977bb86 to your computer and use it in GitHub Desktop.
Save viniceosm/b6748ee3759f9d388fa48a9a2977bb86 to your computer and use it in GitHub Desktop.
Exemplo de promise com async function
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