Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTK Query createApi Help: Any way to merge previous end point state with new response #2270

Closed
kohding opened this issue Apr 21, 2022 · 2 comments

Comments

@kohding
Copy link

kohding commented Apr 21, 2022

I'm trying to find a way to not overwrite the previous responses state, but instead merge it with the new response for the same end point. This would prevent unnecessary load on the server since the data has already been requested on the first request. I also don't see a way to getState before the second request completes. Thanks in advance.

Example
First response.
{ text: 'This is the first response' }

Second response overwrites first response.
{ text2: 'This is the second response' }

What I would like with second response. Take the first response and merge it with the second response using the spread operator or if there is built-in functionality with RTK Query.
{ text: 'This is first response', text2: 'This is the second response' }

@markerikson
Copy link
Collaborator

There's a proposal for this in #1059 , but we haven't gotten it finished yet. I'd like to put it out in RTK 1.9, but no ETA on that atm.

@kohding
Copy link
Author

kohding commented Apr 21, 2022

@markerikson Appreciate the link and responding so quickly. I wasn't sure if this was possible and would've kept wasting time. Thanks

@kohding kohding closed this as completed Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants