rtk-query Questions

3

Solved

According to the redux docs: "While there is less need to store the response in a normalized lookup table with RTK Query managing caching data, transformResponse can be leveraged to do so if d...
Grube asked 24/5, 2022 at 8:51

5

Solved

I wanna send an image with form data to the nest js server with RTK query but the file didn't send. the code are: uploadImage: builder.mutation<any, any>({ query: (imageFile) => { var b...
Puke asked 26/5, 2023 at 12:12

2

Solved

I'm building a project using Redux Toolkit with RTK Query and I am trying to get some entries from an API. I'm using the normalized data approach with the createEntityAdapter and because in a certa...
Haggai asked 9/5, 2023 at 17:41

2

Solved

When we are inside the selector, in order not to violate the rules of hooks, we can use the RTK query endpoint as follows: 1)useQuery const data = datsApi.endpoints.getData.useQuery(someProps) 2)...
Krasnoff asked 5/12, 2022 at 23:22

2

I have the following API defined for the RTK query: export const postsApi = createApi({ reducerPath: "postsApi", baseQuery: fetchBaseQuery({ baseUrl: 'https://myservice.co/api/v2/' }), ...
Manna asked 4/8, 2021 at 8:22

4

I'm trying to test a component in React that uses RTK Query + MSW + Vitest. It works fine on the browser but while testing RTK Query with vitest it throws this error: { status: 'FETCH_ERROR', error...
Brei asked 9/1, 2023 at 11:5

6

Solved

I am using rtq query and i have an endpoint that takes azure-ad oid from the global store and makes a query to the backend to check if the user exists on the backend to check if the user exists. If...
Barograph asked 12/11, 2021 at 19:56

3

Solved

I have a root API where I am injecting endpoints. But when I try to add a transform function it doesn't work. From the documentation of transformResponse I can see that the transform prop is attach...
Glossator asked 11/10, 2021 at 8:16

3

Getting error with RTK query: Type 'FetchBaseQueryError | SerializedError' is not assignable to type 'ReactNode'. const { data, error, isLoading } = useGetDataQuery(); return ( <div>{erro...
Brokenhearted asked 4/3, 2023 at 21:46

4

Solved

What is the proper way to chain queries if the 2nd query requires a parameter that is returned by the 1st? const { data: user } = useGetUserQuery(); The user object contains an ID that is used to ...
Counterstamp asked 9/10, 2021 at 8:40

6

I have some requests which may return 404s. When they do, RTK query will send retries, resulting in hundreds of failed requests. Why is it trying to refetch on error and what can I do?
Subdue asked 3/2, 2022 at 16:58

2

Solved

I am trying to understand how to correctly use SelectFromResult from the official documentation: https://redux-toolkit.js.org/rtk-query/usage/queries#selecting-data-from-a-query-result I have exten...
Addam asked 23/9, 2021 at 10:41

4

Solved

I'm trying to work with RTK Query, but can't find a good example of how to write unit tests with react testing library for a component that uses requests with RTK Query. For example, we have a comp...
Accepter asked 3/6, 2022 at 16:7

3

RTK query seems to work so that when cached results get invalidated, the invalidated query is being re-fetched immediately. I would expect that a re-fetch would execute when the program requests in...
Tench asked 24/8, 2022 at 17:48

3

Solved

Hi I recently learned the new react toolkit with the rtk query tool, and I am trying to put in a login system together using the createApi from the rtk package. After giving it a test on the login ...
Bennir asked 28/8, 2021 at 1:46

2

This is the first time when I setup test environment with RTK Query and mock server (msw). Please tell me what I'm doing wrong. Environment Name Version msw 1.2.1 react 18 redux toolkit...
Fugacity asked 18/4, 2023 at 15:41

2

Solved

I just started on redux yesterday and after reading up on the different libraries, I decided to use the slice route from RTK. For my async, instead of using createAsyncThunk, I decided to use RTK q...
Maryleemarylin asked 6/6, 2021 at 5:13

3

Solved

I tried to combine two RTK reducers, but every time I tried to use concat to include it in the middleware, there will be errors, here's my code store.ts import { configureStore,combineReducers } fr...
Khmer asked 15/11, 2021 at 8:29

3

Solved

I'm trying to test RTKQuery that an endpoint has been called using jest. I eventually want to also be able to mock what the return data will be, but first I wanted to just check that the hook had b...
Officer asked 10/12, 2021 at 19:54

3

Solved

Where is getDefaultMiddleware coming from? I'm reading the docs and it seems to magically appear within configure store. While that's great and all, it didn't find its way into my store, and well ....
Maramarabel asked 8/9, 2021 at 0:33

2

I'm new to RTK query, I'm currently watching a tutorial wherein the RTK query data is stored in a redux slice using ExtraReducers. I'm trying to store RTK query data in a slice state, but unable to...
Blond asked 11/12, 2022 at 4:7

5

Trying to follow the rather sparse tutorial on the official page doesn't get me far. I'm essentially trying to add a certain header based on the params of an api call, but am clueless how to config...
Paviour asked 28/7, 2021 at 13:54

2

I've been trying to figure out why tag invalidation is not working and added some logging. The providesTags in getMe works fine, but invalidatesTags in login is never called. What might be wrong? I...
Meuse asked 22/9, 2021 at 8:1

3

Solved

I use the redux toolkit to create an API The question is short: how to dynamically change the baseUrl in the API? The question in detail: Here is the createApi method An object is passed to this me...
Fault asked 14/10, 2021 at 10:8

3

On my api I have two mutations and strangely, one of them does trigger the refetch but the other doesn't and I have no clue why. Both mutations make their networks calls and changes are reflected i...
Nous asked 28/6, 2021 at 15:23

© 2022 - 2024 — McMap. All rights reserved.