S
S
Simon Tis2021-10-14 13:10:10
React
Simon Tis, 2021-10-14 13:10:10

How to change baseUrl dynamically in redux-toolkit createAPI method?

Hello. I'm using redux toolkit to create an API The
question is short: how to dynamically change baseURL in api ?
Question in detail:
Here is the createAPI method. An
object is passed to this method, one of the keys of which is baseQuery

export const WebApi = createApi({
reducerPath: 'API',

baseQuery: fetchBaseQuery({ baseUrl: ' localhost:3001/api ' }),
endpoints : () => ({}),

});

And here's the question, how do I dynamically change the baseURL? It's in the store, but I can't just take it and put it here.
Tried the solution from the query customization documentation
https://redux-toolkit.js.org/rtk-query/usage/custo...

But it does not allow changing the baseURL, only dynamically processing the request itself, which already comes AFTER baseUrl Who

faced?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question