---
title: "Discussion on \"5 best libraries for making AJAX calls in React\" | Hashnode"
description: "Discussion on \"5 best libraries for making AJAX calls in React\". I have been working with React for the last two years. One of the questions many React beginners ask: \"What's the React way to fetch data from the server\" or \"How should I make AJAX calls in React\"? To answer your question, as many developers would t..."
url: "https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [5 best libraries for making AJAX calls in React](https://hashnode.com/post/5-best-libraries-for-making-ajax-calls-in-react?utm_source=hashnode&utm_medium=feed)

I have been working with React for the last two years. One of the questions many React beginners ask: "What's the React way to fetch data from the server" or "How should I make AJAX calls in React"? To answer your question, as many developers would t...

Aug 24, 2016 · hashnode.com  
Updated Dec 24, 2016  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#reactjs](https://hashnode.com/tag/reactjs)

## Written by

[Sandeep Panda](https://hashnode.com/@sandeep)

@sandeep · Bangalore

  
[View profile](https://hashnode.com/@sandeep)

co-founder, Hashnode

I am the Co-Founder of Hashnode. I write (about) code and keep interest in Venture Funding and startups. Feel free to contact me at sandeep@hashnode.com.

## Responses 13

Markdown supported · ⌘↵ to post

[Timothee](https://hashnode.com/@yooooomi)

[Apr 15, 2020](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/5e96f1d73b68e66b1acbd9fa)

`Request` is deprecated and not maintained anymore :)

[Wassim](https://hashnode.com/@lsabbagh)

[Apr 14, 2018](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/5ad190cd559c159040f073f1)

Can you please check this: [faxios](https://www.npmjs.com/package/faxios)

[Jalaj Sharma](https://hashnode.com/@jalajrocking)

[Jan 5, 2018](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/5a4f44256a61b493714393d1)

Nice article, I would just like to know about your take. Can you tell me why I would like to opt for fetch when we have more cleaner option as axios? I mean no offense, I am just curious to know why should i go with fetch which has comparatively less community support.

[Jordan Brennan](https://hashnode.com/@jordan)

[Apr 20, 2017](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/58f831abb79c6f6bd1d85ecf)

Backbone still has the best API imo:

```
loadCommentsFromServer: function() {
    comments.fetch().then(function(response) {
        // perform setState here
    });
}
```

It's clear what model/resource I'm fetching, no internals like the service URL showing through, and when I get a response I have the additional benefit of the Collection API ready to do things like sort/filter/group the data.

[pingx](https://hashnode.com/@pingx)

[Apr 8, 2017](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/58e8d2bf4f9c8a523038ec4c)

I use fetch API with a tiny wrapper >\_<.

[https://github.com/haoxins/fetch.io](https://github.com/haoxins/fetch.io)

[Tunca](https://hashnode.com/@Tunca)

[Sep 11, 2017](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/58e8d2bf4f9c8a523038ec4c#reply-59b5e8b66ee53a901d0ae5a6)

Is there any way to do basic auth with jsonp get request, using any library except jQuery.

[Tunca](https://hashnode.com/@Tunca)

[Sep 11, 2017](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/58e8d2bf4f9c8a523038ec4c#reply-59b5e8c16ee53a901d0ae5aa)

Is there any way to do basic auth with jsonp get request, using any library except jQuery.

[Nikhil Maheshwari](https://hashnode.com/@Nikmahes)

[Feb 8, 2017](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/589a8296efb8127bc969c329)

I disagree with your Take, Have you tried sending a post request with fetch, it just does't work. By little search you can find the issues with fetch. Nice Article Anyways, Covers Most of the APIs !

[Sandeep Panda](https://hashnode.com/@sandeep)

[Feb 8, 2017](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/589a8296efb8127bc969c329#reply-589a8d1dd9c49b4f1bc3b3b0)

We have been using fetch in production at Hashnode without any problem. And yes, POST requests too.

[Nicholas Stephan](https://hashnode.com/@nicholasstephan)

[Jan 8, 2017](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/587296229576d582d21dd4d5)

Great list of ajax libraries!

But if you're talking about ReactJS specifically, then every one of your examples is, in facebook's own words, an anti-pattern. You're setting state in an asynchronous callback, which means the component could be unmounted by the time the callback is called.

@fibric gets it; calling out qwest's cancellable promises. I'd recommend everyone read this post on React's blog: [facebook.github.io/react/blog/2015/12/16/ismounte…](https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html)

[Harshit Mehrotra](https://hashnode.com/@supra28)

[Feb 11, 2017](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/587296229576d582d21dd4d5#reply-589ecd8b5b2e45fefa52b96f)

You can use axios to cancel requests, [https://github.com/mzabriskie/axios#cancellation](https://github.com/mzabriskie/axios#cancellation)

[Iván Portilla](https://hashnode.com/@ivyk)

[Nov 24, 2016](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/58374e9addfa96eb7c5d4cbb)

Good post, i think you forgot [Got](https://github.com/sindresorhus/got)!

[Chris Williams](https://hashnode.com/@amboy00)

[Aug 26, 2016](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/57c04f8593309a25047c62f6)

Great article!

I would put my vote in for the Fetch API. What I noticed when using Axios (and it is really easy to use and gets points for that) is that it didn't ever work well with unit testing. It may be a matter of using the right version, but mocking calls through axios never resolved. Fetch solved that issue. So if you have to ever test async functions like that, Fetch gets my vote. (\*disclaimer, this is just from my personal experience.)

[Abhishek Jain](https://hashnode.com/@jainabhishek14)

[Aug 19, 2017](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/57c04f8593309a25047c62f6#reply-5998bb7ce7816cd06a19a461)

There is also issues regarding cross domain calls with axios..

[Yanni Nightingale](https://hashnode.com/@yanni4night)

[Aug 25, 2016](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/57be4457387df20e0b9f91e4)

Agree, but **fetch** requires _Promise_, what is the best _Promise_ polyfill ?

[Nicolas Siver](https://hashnode.com/@NicolasSiver)

[Aug 28, 2016](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/57be4457387df20e0b9f91e4#reply-57c2e96093309a25047c64fa)

I think, [https://github.com/stefanpenner/es6-promise](https://github.com/stefanpenner/es6-promise) should work for you.

[Dwayne Charrington](https://hashnode.com/@vheissu)

[Aug 25, 2016](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/57be3ab91351c2290bba1fd9)

How about no library at all and just use a native XMLHttpRequest instead? Fetch is alright, but it has quite a few shortcomings now and you need a polyfill to even use it across browsers. The specification is in flux and until they address the issues like cancellation and monitoring file upload progress.

```
var request = new XMLHttpRequest();
request.open('GET', '/api/content', true);

request.onload = function() {
    if (this.status >= 200 && this.status < 400) {
        var data = JSON.parse(this.response);
    } else {
        console.error('Response received and there was an error');
    }
};

request.onerror = function() {
    console.error('Request error');
};

request.send();
```

[Rommy](https://hashnode.com/@rommyarb)

[Mar 16, 2019](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/57be3ab91351c2290bba1fd9#reply-5c8d30639ee0c53340ffdd39)

Nope

[Dwayne Charrington](https://hashnode.com/@DigitalSea)

[Mar 18, 2019](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/57be3ab91351c2290bba1fd9#reply-5c8f657953cb776827a53b68)

Rommy, you do realise you're responding to a three year old comment, right? Many of these issues have been resolved now.

[Niccolò Brogi](https://hashnode.com/@nbrogi)

[Aug 24, 2016](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/57bdf5edcb80370904fc5628)

I wouldn't even include jQuery...

I doesn't make much sense to load jQuery just to make Ajax calls, and it looks as if the trend is not to use jQuery anymore.

If I had to include it, for sure I wouldn't put it first in the list.

[Sandeep Panda](https://hashnode.com/@sandeep)

[Aug 24, 2016](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/57bdf5edcb80370904fc5628#reply-57bdfc5fcb80370904fc5635)

Yes, that is what I have mentioned in the jQuery section.

[Denny Trebbin](https://hashnode.com/@nerdalytics)

[Aug 24, 2016](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/57bdaa641351c2290bba1f35)

I'll add an alternative library [qwest](http://dreamysource.io/project/qwest)

> Qwest is a simple ajax library based on promises, and that supports XmlHttpRequest2 special data like ArrayBuffer, Blob, and FormData.

```
qwest.get(this.props.url)
     .then(function(xhr, response) {
        // perform setState here
     });
```

The reason why I'm listing it here is that it supports cancellation via

```
const request = qwest.get( /*... */ ).then( /* won't execute */ )
request.abort();
```

When components unmount/unload, call `abort()` to avoid React spamming the console when Ajax ​Promises resolve after the component has unmounted/unloaded from the DOM.

[Sai Kishore Komanduri](https://hashnode.com/@saiki)

[Aug 24, 2016](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/57bdaa641351c2290bba1f35#reply-57bddcf0387df20e0b9f9170)

I believe even `superagent` has support for aborting requests.

[Denny Trebbin](https://hashnode.com/@nerdalytics)

[Aug 24, 2016](https://hashnode.com/posts/5-best-libraries-for-making-ajax-calls-in-react/57bd9cec93309a25047c5f66/comment/57bdaa641351c2290bba1f35#reply-57bde238387df20e0b9f917e)

Yeah, that's right. I favor real promises over fluid apis :-)
