I am new to the RTK Query and I use Redux ToolKit Query to fetch the data. Question: How do I dynamically change the baseUrl in createApi from the input field in App.js file.
I saw similar question here, but the solutions which was provided doesn't work in my case. How to dynamicly chane base URL using redux-toolkit?
export const WebApi = createApi({
reducerPath: 'API',
baseQuery: fetchBaseQuery({ baseUrl: 'http://localhost:3001/api' }),
endpoints: () => ({}),
});
How to make API call from App.js file, where user can put any kind of API link in the input field and get the result.
something like this:
const dynamicUrl = ''
<button className="btn" type="button" onClick={() => refetch(dynamicUrl)}>Fetch Data</button>