async and await let you write asynchronous code that reads from top to bottom.
Direct answer
Put async before a function to make it return a promise. Inside it, use await before a promise to wait for its result. Handle errors with try and catch. It is syntax built on top of promises.
Example
async function getUser(id) {
try {
const response = await fetch(`https://api.example.com/users/${id}`);
const user = await response.json();
console.log(user.name);
} catch (error) {
console.error("Something went wrong", error);
}
}
getUser(1);
Run things in parallel
const [users, posts] = await Promise.all([
fetch("/users").then(r => r.json()),
fetch("/posts").then(r => r.json()),
]);
Awaiting one after another waits for each in turn. Promise.all runs them together.
Common mistakes
- Forgetting
await, so you get a promise instead of data. - Using
awaitoutside an async function (top-level await works only in modules). - Not handling errors.
Where Teyro fits
Teyro's JavaScript for Beginners course turns this into short lessons you can play in a few minutes a day. It has 50 lessons, and you can start free.
The bottom line
Use async, await and try/catch for readable asynchronous code.



