Skip to content

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

Closed
rgbkids wants to merge 1 commit into
reactjs:mainfrom
rgbkids:fix/json-parse
Closed

fix: JSON.parse fails in react-fetch#50
rgbkids wants to merge 1 commit into
reactjs:mainfrom
rgbkids:fix/json-parse

Conversation

@rgbkids

@rgbkids rgbkids commented Aug 8, 2021

Copy link
Copy Markdown

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

gaearon commented Nov 25, 2021

Copy link
Copy Markdown
Member

why is the data empty?

@gaearon

gaearon commented Nov 25, 2021

Copy link
Copy Markdown
Member

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

rgbkids commented Nov 26, 2021

Copy link
Copy Markdown
Author

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