useQuery returning 404 when no data received from axios request #5406
Answered
by
TkDodo
joshtheflame
asked this question in
General
-
I just started learning react.js and using reactQuery. I am using useQuery to fetch all data and rendering on my page which works fine when there is data in the database but with no rows in table and no data returned from the API call its showing 404. Please advise what am I doing wrong? Console when there is a record in database:Console when there are no records in database:My code is like this of API module:
Tasks.jsx of react.js
Error message on console when table has no rows and api returning no values
|
Beta Was this translation helpful? Give feedback.
Answered by
TkDodo
May 13, 2023
Replies: 1 comment 3 replies
-
Your useEffect is wrong. You can't return JSX from an effect and expect it to be rendered on the screen. You probably don't need useEffect |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the console logging is expected in dev mode because react-query logs failed requests to the console.