Skip to content

Conversation

rgbkids
Copy link

@rgbkids rgbkids commented Aug 8, 2021

JSON.parse fails in react-fetch

JSON.parse (empty data) doesn't work properly when I get empty data.
In react-fetch, I get Uncaught Syntax Error.

fetch(`http://localhost:4000/notes/-1`)
  • api.server.js
    • GET: /notes/:id

res.json(rows[0]);

Just escape it like this

res.json(rows[0] || "null");

https://stackoverflow.com/questions/9158665/json-parse-fails-in-google-chrome

@gaearon
Copy link
Member

gaearon commented Nov 25, 2021

why is the data empty?

@gaearon
Copy link
Member

gaearon commented Nov 25, 2021

i'll close because it's not supposed to be empty. if there's some case where it's empty let's figure out why.

@rgbkids
Copy link
Author

rgbkids commented Nov 26, 2021

Please read this.

fix: JSON.parse fails in react-fetch #55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants