Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Built-in Fetch documentation? #25

Open
dathbe opened this issue Mar 25, 2024 · 3 comments
Open

Built-in Fetch documentation? #25

dathbe opened this issue Mar 25, 2024 · 3 comments
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed

Comments

@dathbe
Copy link

dathbe commented Mar 25, 2024

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 either fetch.get(url) or fetch(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.

@KristjanESPERANTO
Copy link
Owner

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 🙂

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.

@KristjanESPERANTO KristjanESPERANTO added documentation Improvements or additions to documentation help wanted Extra attention is needed labels Mar 25, 2024
@dathbe
Copy link
Author

dathbe commented Mar 26, 2024

I have a private module that I need to replace request in. But as far as public modules:

@dathbe dathbe closed this as completed Mar 26, 2024
@dathbe dathbe reopened this Mar 26, 2024
@KristjanESPERANTO
Copy link
Owner

An example of switching from XMLHttpRequest to fetch you can see in this commit dathbe/MMM-CustomMessage@dc74297.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants