I remember back in the days of jQuery
$.ajax was a big, big thing. But nowadays we have
fetch a way cooler, faster and more awesome solution. The best part; it works in
How to make a get request with Fetch permalink
That is as basic as it gets, won't do much since we are not returning any data.
Returning json data with Fetch permalink
// Successfull fetch return as json
// Data now contains the json
// A Error occured
The first response will return an object, not an actual response, so we need to tell the promise chain that we want to return this response as JSON.
You can play around with this codepen.
Browser support permalink
Fetch has excellent support, but not in IE. 😓
You can use a polyfill for this.