I am using:
JavaScript
x
2
1
dispatch(api.endpoints.getPosts.initiate(undefined))
2
But Im receiving following error inside redux:
JavaScript
1
3
1
name:"ConditionError"
2
message:"Aborted due to condition callback returning false."
3
I found the meaning of this error at this question:
It means that an asyncThunk was not executed due to condition. If you are using RTK Query, that just means that another request was skipped because there was either already a request in flight or already a value in cache, so no request needs to be made. This is an internal rejection that RTK-Query uses to track component subscriptions and not an error.
But is there any way to force the refetch?
Advertisement
Answer
Found the solution. You should use {forceRefetch: true}
option:
JavaScript
1
2
1
dispatch(api.endpoints.getPosts.initiate(undefined, {forceRefetch: true}))
2