You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This isn't really node specific, but XMLHttpRequest has long been all-but-replaced by fetch, and it would be nice to add a migration to allow these legacy codebases to run in modern environments, including Node.js
constsignal=AbortSignal.timeout(5000);try{constres=awaitfetch("https://api.example.org/data",{ signal });console.log(awaitres.text());}catch(err){console.error("Request timed out",err);}
Activity
AugustinMauroy commentedon Aug 2, 2026
Definitely good idea ! What about the codemod name something like
@nodejs/xhr-to-fetch?Here the list of all before/after that i had found with migratable patterns
1. Basic GET request
Before:
After:
2. Parsing JSON
Before:
After:
3. POST request with JSON
Before:
After:
4. Custom headers
Before:
After:
5. Handling errors
Before:
After:
6. Query parameters
Before:
After:
7. Abort / timeout
Before:
After:
8. Response status and headers
Before:
After:
9. Downloading binary data
Before:
After: