Last active
June 4, 2019 12:03
-
-
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.
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
<!-- | |
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