Async Await
It is introduce in ES8, is built on top of Promises.
EX 1:
async function playerStart() {
const firstMove = await move(400, 'Left');
await move(400, 'Right');
await move(400, 'Up');
await move(400, 'Down');
}EX 2:
// Basic usage
fetch('https://jsonplaceholder.typicode.com/users')
.then(res => res.json())
.then(console.log);
// using ASYNC AWAIT
async function getUsers() {
const res = await fetch('https://jsonplaceholder.typicode.com/users')
const data = await res.json();
console.log(data); // response
}Last updated