serviejs / popsicle

Simple HTTP requests for node and the browser
MIT License
246 stars 19 forks source link

Advantages over Axios? #104

Closed elado closed 7 years ago

elado commented 7 years ago

I'm debating between this library and axios. What are the major benefits I'll get with popsicle?

blakeembrey commented 7 years ago

You're free to choose whichever you'd prefer, but I mostly wrote this for a couple of reasons:

  1. Simple plugin architecture - it's made things like server testing simple with https://github.com/blakeembrey/popsicle-server (works like supertest)
  2. I wanted progress support (not that I ever really used it, but it is there working)
  3. I needed more functionality that plugins enabled such as proxy agents
  4. I wanted it to be lower level to enable every use-case - couldn't have it erroring on 404 since you might be writing a test suite
  5. Most importantly, I needed the ability to abort requests part way on both node.js and browsers - I use this module heavily on node.js in streaming mode where I want to cancel once I have enough bytes to infer information (e.g. with https://github.com/blakeembrey/node-scrappy I can't be downloading 100MB movies, I only need the initial bytes for the metadata)
  6. First-class TypeScript support - this module was written in TypeScript for TypeScript

Some or most of these are now supported in other request libraries, but at the time most of it wasn't. In the end, I still use popsicle myself because I prefer the modular approach I created with the plugin system. That system enabled projects like https://github.com/serviejs, which is agnostic enough that it might be the next major release of popsicle (the architectures are almost identical today, just one is made for making requests and handling responses while the other is made for handling requests and making responses - it turns out you can make the behaviour on both sides look the same and there's just a transparent network connection in the middle).

Thanks for asking!