const Fly = require('flyio/dist/npm/fly')
let fly = new Fly()
fly.interceptors.request.use(function (request) {
return request
})
fly.interceptors.response.use(
(response) => {
let res = response.data
return res
}, (err) => {
console.log('err:', err)
}
)
export default fly
报错:
{ ReferenceError: XMLHttpRequest is not defined
at new Fly (/Users/ludongwei/project/Unclutter Files/work/nuxt-test/node_modules/flyio/dist/npm/fly.js:176:33)
at Object.84 (core/http.js:4:0)
at __webpack_require__ (webpack:/webpack/bootstrap 2c92f4a5df9d5ced7bac:25:0)
at Object.83 (core/user.js:1:0)
at __webpack_require__ (webpack:/webpack/bootstrap 2c92f4a5df9d5ced7bac:25:0)
at Object.82 (core/index.js:1:0)
at __webpack_require__ (webpack:/webpack/bootstrap 2c92f4a5df9d5ced7bac:25:0)
at Object.65 (pages/user/login.vue?0686:1:0)
at __webpack_require__ (webpack:/webpack/bootstrap 2c92f4a5df9d5ced7bac:25:0)
at Object.57 (pages/user/login.vue:1:0)
at __webpack_require__ (webpack:/webpack/bootstrap 2c92f4a5df9d5ced7bac:25:0)
at <anonymous> statusCode: 500, name: 'ReferenceError' }
代码:
报错:
是不是fly还不支持nuxt的关系呢,其实我想来应该也是没问题的