State Management · Senior · Question 32 of 75
What is transformResponse used for in an RTK Query endpoint?
- ✓Correct answer: Reshaping the raw API response (e.g. unwrapping or normalizing) before it's cached
- 2Converting the request body to JSON
- 3Changing the HTTP method of the request
Explanation
transformResponse: (res) => res.data.items keeps the API quirks out of components and the cache. For normalized caches you can combine it with createEntityAdapter.