alt.hn

4/1/2026 at 8:32:34 AM

Replace axios with a simple custom fetch wrapper

https://kentcdodds.com/blog/replace-axios-with-a-simple-custom-fetch-wrapper

by mariuz

4/2/2026 at 9:04:11 AM

Every team I've seen write a fetch wrapper eventually reimplements half of axios, just worse. The article works for a bookshelf demo app. In production you'll want retries, timeouts, request deduplication, cancellation - and suddenly your "simple wrapper" is a library with no tests and no docs

by hackerman70000

4/1/2026 at 5:47:03 PM

I’m all for replacing as much 3rd party libs with stdlib but it’s hard to look past the storing of the jwt in localStorage. Please don’t do that people. It’s very easily extracted through xss attacks.

by pheew

4/1/2026 at 8:51:49 PM

A cookie is susceptible to both xss and CSRF. You ought to be protecting against xss anyway.

by moi2388

4/1/2026 at 2:17:03 PM

In the case of authentication redirect, any inflight request is going to fail and you're about to navigate in a few milliseconds, so I don't resolve those promises. Return new Promise(() => {}).

by joeframbach