News for hackers. Stuff that matters.
Re:Modern Node.js Patterns by yawnxyz on Sunday August 03, 2025 @04:24PM (#44779448)
node fetch is WAY better than axios (easier to use/understand, simpler); didn't really know people were still using axios
Re:Modern Node.js Patterns by reactordev on Sunday August 03, 2025 @05:32PM (#44780018)
You still see axios used in amateur tutorials and stuff on dev.to and similar sites. There’s also a lot of legacy out there.
Re:Modern Node.js Patterns by bravesoul2 on Sunday August 03, 2025 @06:02PM (#44780221)
AI is going to bring that back like an 80s disco playing Wham. If you gonna do it do it wrong...
Re:Modern Node.js Patterns by macNchz on Sunday August 03, 2025 @06:33PM (#44780410)
I've had Claude decide to replace my existing fetch-based API calls with Axios (not installed or present at all in the project), apropos of nothing during an unrelated change.
Re:Modern Node.js Patterns by int_19h on Monday August 04, 2025 @01:34AM (#44782405)
I had Gemini correct my code using Google's new LLM API to use the old one.
Re:Modern Node.js Patterns by reactordev on Sunday August 03, 2025 @06:27PM (#44780376)
hahaha, I see it all the time in my responses. I immediately reject.
Re:Modern Node.js Patterns by Raed667 on Sunday August 03, 2025 @04:33PM (#44779518)
I do miss the axios extensions tho, it was very easy to add rate-limits, throttling, retry strategies, cache, logging ..

You can obviously do that with fetch but it is more fragmented and more boilerplate

Re:Modern Node.js Patterns by farkin88 on Sunday August 03, 2025 @05:00PM (#44779759)
Totally get that! I think it depends on your context. For Lambda where every KB and millisecond counts, native fetch wins, but for a full app where you need robust HTTP handling, the axios plugin ecosystem was honestly pretty nice. The fragmentation with fetch libraries is real. You end up evaluating 5 different retry packages instead of just grabbing axios-retry.
Re:Modern Node.js Patterns by hiccuphippo on Sunday August 03, 2025 @05:04PM (#44779803)
Sounds like there's space for an axios-like library built on top of fetch.
Re:Modern Node.js Patterns by farkin88 on Sunday August 03, 2025 @05:13PM (#44779872)
I think that's the sweet spot. Native fetch performance with axios-style conveniences. Some libraries are moving in that direction, but nothing's really nailed it yet. The challenge is probably keeping it lightweight while still solving the evaluating 5 retry packages problem.
Re:Modern Node.js Patterns by crabmusket on Sunday August 03, 2025 @05:46PM (#44780111)
Is this what you're looking for? https://www.npmjs.com/package/ky

I haven't used it but the weekly download count seems robust.

Re:Modern Node.js Patterns by farkin88 on Sunday August 03, 2025 @06:15PM (#44780304)
Ky is definitely one of the libraries moving in that direction. Good adoption based on those download numbers, but I think the ecosystem is still a bit fragmented. You've got ky, ofetch, wretch, etc. all solving similar problems. But yeah, ky is probably the strongest contender right now, in my opinion.
Re:Modern Node.js Patterns by hokkos on Monday August 04, 2025 @03:29AM (#44782946)
Like axios can do it if you specify the fetch backend, it just won't do the .json() asynchronously.
Re:Modern Node.js Patterns by tracker1 on Monday August 04, 2025 @12:26PM (#44788044)
I'm actually not a big fan of the async .json from fetch, because when it fails (because "not json"), then you can't peak at the text instead. Of course, you can clone the response, apparently, and then read text from the clone... and if you're wrapping for some other handling, it isn't too bad.
Re:Modern Node.js Patterns by mcv on Sunday August 03, 2025 @06:34PM (#44780417)
This is all very good news. I just got an alert about a vulnerability in a dependency of axios (it's an older project). Getting rid of these dependencies is a much more attractive solution than merely upgrading them.
Re:Modern Node.js Patterns by thewisenerd on Sunday August 03, 2025 @07:19PM (#44780660)
isn't upgrading node going to ba bigger challenge? (if you're on a node version that's no longer receiving maintenance)
Re:Modern Node.js Patterns by mcv on Monday August 04, 2025 @06:06AM (#44783826)
No idea how much compatibility breakage there is, but it's probably going to have to happen at some point, and reducing dependencies sounds worth it to me.
Re:Modern Node.js Patterns by farkin88 on Sunday August 03, 2025 @04:56PM (#44779715)
Right?! I think a lot of devs got stuck in the axios habit from before Node 18 when fetch wasn't built-in. Plus axios has that batteries included feel with interceptors, auto-JSON parsing, etc. But for most use cases, native fetch + a few lines of wrapper code beats dragging in a whole dependency.
Re:Modern Node.js Patterns by benoau on Sunday August 03, 2025 @05:30PM (#44780005)
axios got discontinued years ago I thought, nobody should still be using it!
Re:Modern Node.js Patterns by creatonez on Sunday August 03, 2025 @08:08PM (#44780950)
No? Its last update was 12 days ago
Re:Modern Node.js Patterns by looshch on Monday August 04, 2025 @06:33AM (#44784009)
what about interceptors?
Re:Modern Node.js Patterns by ramesh31 on Monday August 04, 2025 @08:12AM (#44784769)
Interceptors (and extensions in general) are the killer feature for axios still. Fetch is great for scripts, but I wouldn't build an application on it entirely; you'll be rewriting a lot or piecing together other libs.