Fullstack CourseLearn by building
Back to examples

Axios + TanStack Query

Query caches server data; invalidate after you change it.

Week 2 · data

Todos with Query

Add or toggle a todo. Watch status flip to refetching — that is invalidateQueries pulling a fresh list.

queryKey: ["example-todos","all"]
status: loading
fetches: 0

Loading list…

queryKey: ['todos', filter]
queryFn: () => todosApi.list(filter)
// after mutate:
queryClient.invalidateQueries({ queryKey: ['todos'] })

Query owns the cached list. After a mutation, invalidate so the UI refetches — do not mirror the Nest array in Redux.

Real Nest health (same client)

Loading health…

Same pattern against Nest via @/lib/api. If this errors, start the API and refresh.