这是我的代码:
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var xhr = new XMLHttpRequest();
xhr.open("GET", "//URL")
xhr.setRequestHeader("Content-Type: application/json", "Authorization: Basic //AuthKey");
xhr.send();
我得到了一个错误:
Cannot find module 'xmlhttprequest'
当我删除第一行时,我得到:
XMLHttpRequest is not defined
我搜索了所有地方,人们提到了Node的一个问题.js,但我的节pip安装是正确的,所以我不确定问题出在哪里.