That is an excellent point on not mutating the global state. Thanks for the callout. The main point I was trying to make is to always encapsulate(wrap).
I'll do an edit sometime during the day to reflect this.
To reinvent the wheel or not to
This topic is very subjective, so I'll have to answer subjectively. Having written and made HTTP requests in another language (i.e. go and rust) in the past year, returning to fetch didn't seem like a lot of work.
Arguably, many of the JS libraries out there are reinventing the wheel for better or worse.
At the end of the day, it's up to your team to decide how much re-invention is too much reinvention.
On whether one is superior to the other
This is not a subjective one, so here are my plus for fetch
It's in the browser forever, so your code is insured for life
Whatever abstraction you choose to build on it belongs to your team. Fortunately, from most codebases I've worked on, your HTTP client root config is usually the least touched module as your codebase grows.
It's faster: Checking some random benchmarks on the internet, fetch always comes out at least 2x faster than axios. This is not important to me because as your team builds its abstraction over fetch, your requests might get slower.
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
On Not Mutating Global State
That is an excellent point on not mutating the global state. Thanks for the callout. The main point I was trying to make is to
always encapsulate(wrap).In my codebase, it looks something like this.
I'll do an edit sometime during the day to reflect this.
To reinvent the wheel or not to
This topic is very subjective, so I'll have to answer subjectively. Having written and made HTTP requests in another language (i.e. go and rust) in the past year, returning to
fetchdidn't seem like a lot of work.Arguably, many of the JS libraries out there are reinventing the wheel for better or worse.
At the end of the day, it's up to your team to decide how much re-invention is too much reinvention.
On whether one is superior to the other
This is not a subjective one, so here are my plus for
fetch