TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Safe Data Fetching in Modern JavaScript

2 pointsby steve8708over 2 years ago

1 comment

phillipseamoreover 2 years 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.