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

1

5

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?

Roughen answered 30/7, 2022 at 15:22 Comment(2)
http interceptors ?Bodrogi
It is very simple to achieve How can we intercept APIs using RTK-query createApi ?Roughen
L
7

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:

Lauree answered 31/7, 2022 at 20:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.