Learning Goals
- Use
fetchto request data. - Use
awaitandtry/catch. - Show success and error states.
Async JavaScript
Get data from the internet, handle errors, and complete your beginner capstone projects.
fetch to request data.await and try/catch.async function loadUsers() {
try {
let response = await fetch("https://jsonplaceholder.typicode.com/users");
let users = await response.json();
console.log(users);
} catch (error) {
console.error("Could not load users", error);
}
}
loadUsers();
let.