I’ve been poking around the different HTTP agents, and I think axios is my favourite compared to request or superagent.
- Most importantly, axios provides its own type definitions for TypeScript. That’s just super nice. Request and superagent both have types in DefinitelyTyped, but they’re out of date because they aren’t maintained with the project.
- axios has a very nice concept of Interceptors which allow the request to be modified or inspected before it is sent. In my particular case, I wanted to inspect the body of the request and axios offered a nice public API for me to do that.
- axios supports import … from syntax; the others do not.
- Request bundles form-data which seems nice at first glance, but actually ends up being unpleasant. With Request, the bundled version is out of date and is missing both TypeScript type definitions and a handy new getBuffer() function. It’s better to just import form-data yourself, if needed, and pass the prepared object to the HTTP agent (as a stream, Buffer, or FormData as desired). These concerns are easily separated.
- Request doesn’t use a promises interface by default (the others do) and that requires importing one of three promise wrappers. (edited)