Learn Fetch API In 6 Minutes

45
18



Accessing data from an API is one of the most common things you will do in web development, and the way to access APIs is with fetch. Fetch is function built into JavaScript that allows you to query any URL/API to get back data. The most important part is that fetch is asynchronous so it will run in the background and let you know when it finishes using promises. In this video I will show you exactly how to use fetch, and all of the common mistakes people make using fetch so you can get up and running in just six minutes.

📚 Materials/References:

Learn Promises In 10 Minutes Video:
Async Await Tutorial:

🧠 Concepts Covered:

– What the fetch API is
– How to use the fetch API
– How to handle API response errors
– How to use JSON data with fetch

🌎 Find Me Here:

My Courses:
Patreon:
Twitter:
Discord:
GitHub:
CodePen:

#Fetch #WDS #JavaScript

Nguồn: https://thegioiinuv.com/

Xem thêm bài viết khác: https://thegioiinuv.com/lap-trinh-php/

45 COMMENTS

  1. I'm not to sure how to make a javascript fetch URL where you paste it in the bar on a browser then it sends back the cookies

  2. Hey Kyle,
    you really should blink man. I have been watching your videos for a long time now and you not blinking your eyes as often as they should always catches me off-guard. Just a suggestion, no biggies… 🙂

  3. Thanks Kyle good overview BUT its IMPOSSIBLE to talk about all offer the api in 6 min
    you for instance did not mention the finally block which was recently added to fetch (es-9 or es10 dont recall)
    sometimes you would want to make appear again an html element whatever it was successful or in error:
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally

  4. Bravo!
    My first ever video of your channel. Well explained in actually 6 mins. No bullshit.
    PS: This is the first time I came across fetch. I have been using axios but NOW I think fetch is also nice!

  5. Your habit of staring unblinkingly into the camera is terrifying, but this tutorial is really helpful so I guess I'll just live with the nightmares.

  6. Please, could you show us the content of the file located in https://reqres.in/api/users? I'm confused if I'm on the backend or the frontend

  7. i have this error Access to fetch at 'https://regres.in/api/users' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
    fetch.js:3 GET https://regres.in/api/users net::ERR_FAILED
    (anonymous) @ fetch.js:3
    fetch.html:1 Uncaught (in promise) TypeError: Failed to fetch

  8. your videos should've appeared earlier for me they are very useful man, that only the second video I see in your channel and I am activating the bell Icon

LEAVE A REPLY

Please enter your comment!
Please enter your name here