Axios or Request, choose your soldier

xXAlphaManXx
xXAlphaManXx
Published in
2 min readDec 11, 2017

It is always a daunting task to select the library that suits you. Each library has it’s own features, weakness and strengths. As a beginner, its really difficult to take the best one from the NPM ecosystem. So, I am laying down some examples and comparing each other. It is your choice to take the one it feels for you.

Axios — Promise based request client

Axios is the second most trending request client while the first place goes to Request library. But hey, Axios is now the gaining love and support from all the sides and will eventually surpass Request. Let’s look why.

Pros

  • Promise based client
  • Only 2 dependencies
  • Can be used in the browser too.
  • Faster and clean syntax than Request library

Cons

  • Works on node with prebuilt promise support. Older version requires Bluebird or Q promise
  • Anything else? I don’t think so

Now, let’s look how simple the code to make a simple get request to a domain and getting response is.

Axios — A Promise based HTTP request client

Request — Simplified HTTP client

Request is the first library that comes into mind when you ask people what other developers use in their project to make HTTP requests. It has more number of contributors and user base. But, then when developers started looking at speed, they’ve started using Axios. Now let’s compare

Pros

  • Widely used
  • Has more downloads
  • More bug fixes (releases) than Axios client
  • Only one function, can handle error, the response and the body of content

Cons

  • Has more dependencies (22). We are looking at you Request 😜
  • Slower than Axios
  • Cannot be used outside Node framework

Now, let’s look how simple the code to make a simple get request to a domain and getting response is.

And, provided that we have discussed about those, it is clear to say that both of these clients win over each other in different ways. It now depends upon you. If you prefer speed and love to play with promises then go for Axios. Or if in case you wanna go with simplicity and get-the-job-done then go for Request.

If you like this post or had helped you in any way, please give me a couple of applauds. That really boosts me to write more.

~xXAlphaManXx

--

--

xXAlphaManXx
xXAlphaManXx

Developer, designer, system engineer. What more should I write?