February 2018
Intermediate to advanced
298 pages
8h 22m
English
One of the coolest async APIs introduced in browsers is the Fetch API, which is the modern replacement for the XMLHttpRequest API. Have you ever found yourself using jQuery just for simplifying AJAX requests with $.ajax? If you have, then this is surely a golden API for you, as it is natively easier to code and read!
If you remember, we created a promised version of XMLHttpRequest ourselves in Chapter 4, Asynchronous Programming. However, fetch comes natively, hence, there are performance benefits. Let's see how it works:
fetch(link) .then(data => { // do something with data}).catch(err => { // do something with error});
Awesome! So fetch uses promises! If that's the case, we can combine it with ...
Read now
Unlock full access