You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`args` - The return value of the `query` function for a given endpoint
64
+
-`api` - The `BaseQueryApi` object, containing `signal`, `dispatch` and `getState` properties
65
+
-`signal` - An [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) object that may be used to abort DOM requests and/or read whether the request is aborted.
66
+
-`dispatch` - The `store.dispatch` method for the corresponding Redux store
67
+
-`getState` - A function that may be called to access the current store state
68
+
-`extraOptions` - The value of the optional `extraOptions` property provided for a given endpoint
Called with the same arguments as `baseQuery`, as well as the provided `baseQuery` function itself. It is expected to return an object with either a `data` or `error` property, or a promise that resolves to return such an object.
See also [Customizing queries with queryFn](../usage/customizing-queries.mdx#customizing-queries-with-queryfn).
310
349
311
-
In some cases, you may want to manipulate the data returned from a query before you put it in the cache. In this instance, you can take advantage of `transformResponse`.
312
-
313
-
By default, the payload from the server is returned directly.
314
-
315
-
```ts
316
-
function defaultTransformResponse(baseQueryReturnValue:unknown) {
-`args` - The argument provided when the query itself is called
377
+
-`api` - The `BaseQueryApi` object, containing `signal`, `dispatch` and `getState` properties
378
+
-`signal` - An [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) object that may be used to abort DOM requests and/or read whether the request is aborted.
379
+
-`dispatch` - The `store.dispatch` method for the corresponding Redux store
380
+
-`getState` - A function that may be called to access the current store state
381
+
-`extraOptions` - The value of the optional `extraOptions` property provided for the endpoint
382
+
-`baseQuery` - The `baseQuery` function provided to the api itself
In some cases, you may want to manipulate the data returned from a query before you put it in the cache. In this instance, you can take advantage of `transformResponse`.
349
393
350
-
interfacePost {
351
-
id:number
352
-
title:string
353
-
}
394
+
See also [Customizing query responses with `transformResponse`](../usage/customizing-queries.mdx#customizing-query-responses-with-transformresponse)
Copy file name to clipboardExpand all lines: docs/rtk-query/usage/cached-data.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1010,8 +1010,8 @@ The Redux docs have always recommended [keeping data in a normalized lookup tabl
1010
1010
1011
1011
There are a couple additional points that can help here:
1012
1012
1013
-
- The generated query hooks have [a `selectFromResult` option](../api/created-api/hooks.mdx) that allow components to read individual pieces of data from a query result. As an example, a `<TodoList>` component might call `useTodosQuery()`, and each individual `<TodoListItem>` could use the same query hook but select from the result to get the right todo object.
1014
-
- You can use the [`transformResponse` endpoint option](../api/createApi.mdx) to modify the fetched data so that it's stored in a different shape, such as using `createEntityAdapter` to normalize the data _for this one response_ before it's inserted into the cache.
1013
+
- The generated query hooks have [a `selectFromResult` option](../api/created-api/hooks.mdx#selectfromresult) that allow components to read individual pieces of data from a query result. As an example, a `<TodoList>` component might call `useTodosQuery()`, and each individual `<TodoListItem>` could use the same query hook but select from the result to get the right todo object.
1014
+
- You can use the [`transformResponse` endpoint option](../api/createApi.mdx#transformresponse) to modify the fetched data so that it's [stored in a different shape](./customizing-queries.mdx#customizing-query-responses-with-transformresponse), such as using `createEntityAdapter` to normalize the data _for this one response_ before it's inserted into the cache.
0 commit comments