more and more people are getting tired with the idea of bundling external libraries in their own service / library.
Can I just call another endpoint without adding ‘fetch’, ‘axios’ or anything ? Adding them is automatically enabling the burden of maintaining a package-lock file + future upgrades + git bots to keep everything up to date.
My purpose is just to have the smallest possible JS bundle.
So I have done a budget version of fetch with the just the relevant and meaningful code, able to fetch data from a remote endpoint.
To make it compatible with isomorphic-fetch, an async json() function exists to collect the result as a json object.
The result is a drop-in replacement for that library, but also for window.fetch or deno’s fetch function.
Even with this small snippet, you already get the request + the response + the decompression of the response body. And of course, everything here uses built-in node.js capabilities.