-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Calling await
on an unwrapped lazy query trigger does not actually wait for the request
#3662
Comments
if you don't call unwrap, what does the promise return? |
+1. I think I am seeing the same problem: #3706 |
Can you try the latest CodeSandbox CSB build from #3089 and see if this is resolved? |
I'm going to assume that this is fixed by #3709 , and that fix is available in https://github.com/reduxjs/redux-toolkit/releases/tag/v2.0.0-beta.4 . Please let us know if there's further issues! |
Has anyone confirmed that this is resolved? I think I'm still seeing it in 2.2.6. |
We had another related issue filed in #4650 and found what we think was the actual bug. This should now be fixed as of #4651 and is out in https://github.com/reduxjs/redux-toolkit/releases/tag/v2.2.8 |
Redux toolkit version
I tried looking at existing issues for a similar problem but I did not find anything. I found #3515 but that seems to be more stylistic in nature. What I'm experiencing is either a bug or I am misunderstanding the documentation.
I'm trying to manually trigger a query to the server (i.e. don't use any cached data). This seems like a great use case for useLazyQuery. It looks like I should be able to call
.unwrap()
after calling the trigger and receive the data or have the exception thrown once the promise is resolved or rejected. However that's not what is happening for me. Interestingly, this same pattern works fine for mutations.I have some code like the following:
What I'm noticing is that
userTriggerResult
is undefined when I print it anduser
is a resolved user.useLazyGetUserQuery
andgetUser
are hitting the same endpoint - I copiedgetUser
to demonstrate that it's just anaxios
query and that works fine. For now I am getting around this issue by using a rawaxios
query but I'd like to keep everything uniform. And like I said the mutation works like a charm - in the above snippet the console correctly prints out the signin response.Am I misunderstanding or mis-using something? If I can provide any more information please just let me know what to provide.
Thanks in advance!
The text was updated successfully, but these errors were encountered: