Y
Hacker News
new
|
ask
|
show
|
jobs
Safe Data Fetching in Modern JavaScript
(
builder.io
)
2 points
by
steve8708
1255 days ago
1 comments
phillipseamore
1255 days ago
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.
link