Search code examples
reactjstypescriptredux-toolkitrtk-query

What addon axios have that RTK query fetchBaseQuery util is missing?


In the documentation of the RTK query, this is the introduction that is provided to the fetchBaseQuery util:

This is a very small wrapper around fetch that aims to simplify requests. It is not a full-blown replacement for axios, superagent, or any other more heavy-weight library, but it will cover the large majority of your needs.

OK, I get that fetchBaseQuery isn't perfect, but when should I use fetchBaseQuery over axios or superagent?

What are the tradeoffs?


Solution

  • fetchBaseQuery pretty much supports everything that fetch supports (since it only calls fetch) - which is the modern browser api for interaction with remote data sources. To my knowledge, there is at this point only one feature that fetch does not support, but which is supported by the older XMLHttpRequest (which is uses by axios) does support: file upload progress. But since RTK Query itself only tracks the "started" and "finished" state of a query, you would not be using that with RTK Query in the first place.

    So, nothing really comes to mind.

    You'd really just add 6kb extra to add a tool because you're used to it. There isn't a lot of a reason to use axios nowadays.

    See more: