Skip to content

Instantly share code, notes, and snippets.

@tiagomatosweb
Last active June 4, 2019 12:03
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 tiagomatosweb/82a57a2fa27639858a5d8c072abb995e to your computer and use it in GitHub Desktop.
Save tiagomatosweb/82a57a2fa27639858a5d8c072abb995e to your computer and use it in GitHub Desktop.
O async/await é uma técnica para literalmente transformer sua função em função assíncrona.
<!--
Assista o vídeo dessa aula: https://youtu.be/3158VWp1L9I
Se inscreva no canal https://youtube.com/tiagomatosweb
-
Valeu jovem
TM ;)
-->
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Conhecendo Async/Await</title>
<script type="text/javascript">
async function getPosts() {
try {
var response = await fetch('https://jsonplaceholderassas.typicode.com/posts');
var posts = await response.json();
} catch(e) {
console.log(e);
}
}
getPosts();
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment