Open dathbe opened 6 months ago
The main advantage of the fetch API is that it works in the browser as well as in node without external packages. It is relatively new, but is now supported by all browsers and node.
In most cases it can replace the other variants (axios, request and node-fetch). I have already converted some modules accordingly. If you like, show me a module that you would like to convert and I'll take a look at it :slightly_smiling_face:
Here is a documentation of the fetch API:
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
provide links to some documentation or instructions
Yes, that would be nice. I think especially for fetch and for ESLint that would be helpful.
I have a private module that I need to replace request
in. But as far as public modules:
An example of switching from XMLHttpRequest to fetch you can see in this commit https://github.com/dathbe/MMM-CustomMessage/commit/dc74297f9ba512d6f8f169bb10b23a54406c5497.
The recommendations page recommends replacing functions like axios and node-fetch with a built-in fetch function. But I can't find documentation on how the fetch function works. (changing
axios.get(url)
to eitherfetch.get(url)
orfetch(url)
does not work). Where can I find the documentation?In general, and I know this is a work in progress, it would be good to provide links to some documentation or instructions when substantive recommendations are made.