Skip to content

Instantly share code, notes, and snippets.

@kutyel
Forked from Jviejo/asyncawait.ts
Last active August 8, 2017 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kutyel/e5c981a11019688b1457 to your computer and use it in GitHub Desktop.
Save kutyel/e5c981a11019688b1457 to your computer and use it in GitHub Desktop.
async / await, finally in ES2017
// las funciones con await deben de tener el prefijo async
async function main () {
try {
const result = await pedirPermisos();
// dependemos del servicio anterior para realizar el siguiente
if (result) {
const geolocation = await llamarAPIGoogleMaps();
console.log(geolocation);
}
// si hay algún error, se ejecuta el catch
} catch (err) {
console.error(err);
}
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment