DEV Community

Cover image for What the Fetch

What the Fetch

Brian Greig on July 21, 2018

This fetch API is pretty nifty. If you have worked with JavaScript's XMLHttpRequests in the past or if you had to rely on libraries like jQuery or...
Collapse
 
rpalo profile image
Ryan Palo

Awesome write up! Thanks for laying out some clear examples. Bookmarking this for everytime I want to make an api call and can't remember exactly what the syntax is. :)

In case anyone's interested, the support for fetch is actually pretty good! Opera Mini and IE11 are the only browsers that need a polyfill.

Collapse
 
ignoreintuition profile image
Brian Greig

Good catch. Depending on your audience that is pretty decent coverage.

Collapse
 
bias profile image
Tobias Nickel

you might change the parameter 'e' to url in getData and postData, otherwise you will only use the 'url' from the outer scope.

other then that the methods are very handy and can help to write cleaner code.

thanks for sharing

Collapse
 
ignoreintuition profile image
Brian Greig

Good eye. I completely missed that because the code executed using the globally scoped variable. It is fixed now. Thanks.

Collapse
 
itsasine profile image
ItsASine (Kayla)

Making fetch happen

Collapse
 
alephnaught2tog profile image
Max Cerrina

When I loaded this page I was literally thinking "if there isn't a comment from Mean Girls"...!

Collapse
 
ignoreintuition profile image
Brian Greig

Truth

Collapse
 
bohdanstupak1 profile image
Bohdan Stupak

Hi! Thanks for the good article. I wonder tho if you already have a method postData which does PUT what will happen when you'll need a method which actually does POST.
Have a nice day! :)