r/javascript • u/Ecstatic_Ad_6153 • Sep 01 '25
Stop writing try/catch around fetch — I built safe-fetch (tiny, 0 deps, ~3kb)
https://github.com/asouei/safe-fetchI was tired of wrapping every fetch in try/catch and guessing if the error is network, timeout or HTTP. So I made safe-fetch:
no throws, always returns { ok: true | false }
normalized errors (Network, Timeout, Http, Validation)
dual timeouts + smart retries
~3kb, zero dependencies
1
Upvotes
18
Sep 02 '25
[removed] — view removed comment
12
u/Ecstatic_Ad_6153 Sep 02 '25
Yep, it’s still there — but hidden away, normalized, and wrapped with retries, timeouts and typed errors. Like how you don’t hand-write TCP packets even though HTTP is just wrapping them.
5
3
u/polaroid_kidd Sep 05 '25
what was your inspiration for building this and not using something like ky (179 kB (unpacked))