-
-
Save kutyel/e5c981a11019688b1457 to your computer and use it in GitHub Desktop.
async / await, finally in ES2017
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
// 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