I have tried with this code in JavaScript as follows:
var XMLHttpRequest = require("xmlhttprequest");
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://www.codecademy.com/",true);
xhr.send();
console.log(xhr.status);
console.log(xhr.statusText);
When I run this code using node.js at Command Prompt "node ***.js", an error message comes out saying that 'TypeError: XMLHttpRequest is not a constructor'. I appreciate for any help for why this error. Thanks.
node.jshasn't direct Ajax- API's. You must use Third-Party modules or thenetcomponent fromnode.js