我正在从一个简单配置的实例GET
发出请求:axios
var Axios = axios.create({
baseURL: myBaseUrl,
headers: {'content-type': 'application/json'}
});
Axios.get(url)
并收到以下错误:
ReferenceError: XMLHttpRequest is not defined
at dispatchXhrRequest (C:\...\node_modules\axios\dist\axios.js:804:24)
at xhrAdapter (C:\...\node_modules\axios\dist\axios.js:796:11)
at process._tickCallback (internal/process/next_tick.js:103:7)
at Function.Module.runMain (module.js:577:11)
at startup (node.js:160:18)
at node.js:456:3
据我了解(并根据文档),axios 应该在 web 浏览器和 node.js 上都可以工作。
我错过了什么?
版本:
node - 6.2.1
axios - 0.13.1