This is my code:
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var xhr = new XMLHttpRequest();
xhr.open("GET", "//URL")
xhr.setRequestHeader("Content-Type: application/json", "Authorization: Basic //AuthKey");
xhr.send();
I am getting the error:
Cannot find module 'xmlhttprequest'
When I remove the first line, I am getting:
XMLHttpRequest is not defined
How to fix it?