In this video, we will look at how to use Async / Await with the Fetch API. First, we have to understand the concepts of callbacks and promises. We also need to understand thenables and how async / await replaces them in our code. The first 30 minutes covers the concepts. The last 30 minutes gives examples of retrieving data from different APIs.
Was this tutorial about the JavaScript Fetch API, Async/Await, Promises, Thenables, and Callbacks helpful? If so, please share. Let me know your thoughts in the comments.
2
u/DaveOnEleven Feb 14 '21
In this video, we will look at how to use Async / Await with the Fetch API. First, we have to understand the concepts of callbacks and promises. We also need to understand thenables and how async / await replaces them in our code. The first 30 minutes covers the concepts. The last 30 minutes gives examples of retrieving data from different APIs.
Subscribe ➜ https://bit.ly/3nGHmNn
✅ Quick Concepts outline:
Fetch API with Async / Await
(0:00) Intro
(0:29) What is a callback function?
(1:15) What is the problem with callbacks?
(3:00) JavaScript Promises have 3 states
(5:28) A promise may not return a value where you expect it to: You need to wait for a promise to resolve
(6:58) Using thenables with a promise
(20:15) An easy mistake to make with promises
(24:00) Creating an async function
(25:00) Applying await inside the function
(33:45) Example 1: Retrieving user data
(40:00) Example 2: Retrieving dad jokes
(47:00) Example 3: Posting data
(49:40) Example 4: Retrieving data with URL parameters
(54:55) Abstract it all into single responsibility functions
🤖 APIs used in the examples for this tutorial:
• https://jsonplaceholder.typicode.com/
• https://icanhazdadjoke.com/
• https://httpbin.org/
• http://www.icndb.com/api/
Was this tutorial about the JavaScript Fetch API, Async/Await, Promises, Thenables, and Callbacks helpful? If so, please share. Let me know your thoughts in the comments.
Async Await Javascript with Fetch API Examples: https://youtu.be/VmQ6dHvnKIM