the code you provided uses the XMLHttpRequest object, which is used to make HTTP requests from a web browser.
If you want to make HTTP requests from a Node.js script, you will need to use a different library. There are several options available, but a popular choice is the request library. You...