这是我的代码:XMLHttpRequest的模块/发现
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在这里和那里的问题,但我的节点安装是正确的,所以我不知道问题是什么。
使用'http'代替 – Tushar