Closed st-schneider closed 6 years ago
Hi thanks for asking !
I'll try to point out some of the advantages.
First, the syntax is different. I don't know any other library which uses immutable objects and merges configurations the way wretch does. If you have a big codebase, you can reuse wretch objects to perform requests with small variations (headers, urls, method, authentication ...) very easily.
About XMLHttpRequest, it is not compatible with service workers. Which means that if you want to make a progressive web app it's a no-go. And fetch
is the new standard now anyway supporting body streaming and cross origin requests.
There's also the size, wretch is really small which is important for some people targeting mobile (or low-bandwidth) users.
And wretch is compatible with any fetch polyfill, which means that you can use it for server side rendering. And use the exact polyfill you want, up-to-date (many wrappers are bundled with a specific one).
I just came across wretch. And from the description, it sounded a bit like r2 for example. When it comes to xmlhttprequest/fetch wrappers I'm always asking myself, how is this framework different from the others? I could still use axiom for example. Sure it still uses the oldie but goldie xmlhttprequest instead of fetch. But it also handles the 404 stuff and json repsonses and so on.