Safe Data Fetching in Modern JavaScript
builder.io
Safe Data Fetching in Modern JavaScript
1–2 of 2 posts
Re: Safe Data Fetching in Modern JavaScript
#2One 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.