Fetch and Async/Await
Fetch and Async/Await: Fetch, Async and Await.
Updated
- Fetch (Apprentice): The browser's fetch function sends HTTP requests from JavaScript and returns a promise of the response. Chain .then to read the JSON, check response.ok before trusting it, and pass an options object to POST, PUT or DELETE.
- Async and Await (Journeyman): JavaScript has async and await too, working just like C#'s. An async function can await a promise, such as fetch's, and read like ordinary code, with try and catch for errors. Use it to load data into the page and send a form to an API.