最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Any way to force refetch when using endpoint "initiate" function of redux-toolkit - Stack Overflo

programmeradmin4浏览0评论

I am using:

dispatch(api.endpoints.getPosts.initiate(undefined))

But Im receiving following error inside redux:

name:"ConditionError"
message:"Aborted due to condition callback returning false."

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 ponent subscriptions and not an error.

But is there any way to force the refetch?

I am using:

dispatch(api.endpoints.getPosts.initiate(undefined))

But Im receiving following error inside redux:

name:"ConditionError"
message:"Aborted due to condition callback returning false."

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 ponent subscriptions and not an error.

But is there any way to force the refetch?

Share Improve this question edited May 31, 2022 at 18:51 Rashomon asked May 31, 2022 at 15:11 RashomonRashomon 6,8024 gold badges39 silver badges80 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

Found the solution. You should use {forceRefetch: true} option:

dispatch(api.endpoints.getPosts.initiate(undefined, {forceRefetch: true}))

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论