Tech Standards: Superagent

by Mike Ryan

At Tes, we use superagent as our standard request library.

Three years ago, a review of our codebase showed that we had six different request libraries in use on the client side across our different services: superagent, isomorphic-fetch, browser-request, whatwg-fetch, reqwest, and axios.

Engineers had a discussion to try to find a single library to meet all our needs.

The final criteria used to make the decision were:

  • The library must work on both the client side and server side (eliminated node-fetch as a possibility)
  • The library must be supported across all major browsers (eliminated fetch as a possibility, since it was not supported in IE or Safari at the time, and still isn’t supported in IE 11)
  • The library should be actively maintained (eliminated browser-request and reqwest)
  • It should support standard Promises (eliminated browser-request and reqwest)
  • It should support timeouts (eliminated fetch)
  • It should support the cancelling of requests (eliminated fetch)

This left superagent and axios. The decision to go with superagent came down to the fact that axios still hadn’t had a major release, and the fact that many of our services were already using supertest, which is based on superagent, in their test suites.