Explanations on why this library was made despite there being many libraries already out there.
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
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).
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.