Hacker News new | past | comments | ask | show | jobs | submit login
Safe Data Fetching in Modern JavaScript (builder.io)
2 points by steve8708 on Jan 16, 2023 | hide | past | favorite | 1 comment



One thing missing there, you can't be certain that the response is JSON, so I do a JSON.parse in a try/catch and parse response.text(), if it fails the catch returns the text in the promise.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: