Skip to content

Latest commit

 

History

History
27 lines (14 loc) · 1.36 KB

COMPARISON.md

File metadata and controls

27 lines (14 loc) · 1.36 KB

Comparison to other AJAX libraries/solutions

Explanations on why this library was made despite there being many libraries already out there.

Why not use fetch?

Fetch is sometimes cumbersome:

  • Must set Content-Type header and encode body manually when sending JSON
  • Must call response.json() always when retrieving JSON
  • Forces proper CORS always
  • Does not reject on 4xx or 5xx responses status codes, only on network errors

Why not use axios?

Axios has a history of issues related to global defaults and side-effects (some severe). Some have been fixed but more still arise.

It is cumbersome and error-prone to set request configuration with a (nested) object. Also, this design sometimes leads to cumbersome workarounds (e.g. unsetting a header value).

Why not use jQuery.ajax?

If you have it in your project, sure. Not that common anymore.

Worth noting that older versions of jQuery, still widely in use, implement a broken Promise implementation.