2

I had used refetchInterval before and it was very straightforward. For some reason I can't get it working anymore now.

This code only calls the API only once.

const { data, isFetching } = useQuery(
  ['test'],
  () => axios.get('https://jsonplaceholder.typicode.com/todos/1'),
  { refetchInterval: 3000 }
)
console.log('isFetching=', isFetching)

It prints this at the beginning

isFetching= true
isFetching= false

then only prints this every 3 seconds

isFetching= false

If I manually click the blue "Refetch" button in the reactQueryDevTool, it will also print isFetching= false once, without making any network call.

Why is it only making network call once in the beginning? What am I missing?

EDIT:

I found why! This project has an axios cache set up!!

Aximili
  • 28,626
  • 56
  • 157
  • 216

0 Answers0