TanStackT
TanStack3y ago
2 replies
faint-white

useQuery Fetching twice?!

hi, i am new the tanstack query. this is my first time using, i followed the guide, however when call "onRefreshCaptcha" the network fetch is doing twice for "captcha_img"

` const isImgLoading = ref(false) const queryClient = useQueryClient() const { data, isFetching, suspense } = useQuery({ queryKey: ['api/agent/v1/captcha_img'], onSuccess: () => { isImgLoading.value = true console.log('api/agent/v1/captcha_img', data.value) emit('success', data.value) } }) const onRefreshCaptcha = async () => { queryClient.invalidateQueries({ queryKey: ['api/agent/v1/captcha_img'] }) } await suspense() return { data, onRefreshCaptcha, isFetching, isImgLoading } ~
image.png
image.png
Was this page helpful?