From the course: Mastering Web Developer Interview Code

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

How do you use the Fetch API?

How do you use the Fetch API?

- [Instructor] Fetch is the next generation API for performing AJAX requests. It's a lot simpler and easier to use than XML HTTP request, which is the old way of performing AJAX requests. So let's take a look at some of the features. Now, the main difference, besides being much easier to pronounce, is that Fetch uses promises, which makes it easier to set up operations and change sequences of events outside the request. The API is also built so that it's super easy to use if all you want to do is load up an external file. But it also gives you complete control over the request. As a matter of fact, it returns full information about the request, and can be set up to specify the verb, header information, or get data like the URL, refer and much more. The Fetch API also provides utilities so that the content can easily be parsed as JSON, text, blobs or others. So it makes it easier to process the request. So let's go ahead…

Contents