Closed jackluo2012 closed 6 years ago
`const flyio = require("flyio"); //添加请求拦截器 flyio.interceptors.request.use((request) => { request.baseURL = baseURL; //给所有请求添加自定义header request.headers["X-Tag"] = "flyio"; request.url = request.url + "?beid=3";
//打印出请求体 console.log(request.body); //终止请求 return request; }); //添加响应拦截器,响应拦截器会在then/catch处理之前执行 flyio.interceptors.response.use( (response) => { Toast(response.data.status) if(response.data.status == 1){ return response.data.result } }, (err) => { console.log(err); //发生网络错误后会走到这里 //return Promise.resolve("ssss") } )
// get export const _get = (req) => { return flyio.get(req.url,req.data) }
// post export const _post = (req) => { return flyio.post(req.url, req.data) } `
你的请求是不是夸域的?对于非简单的跨域请求,浏览器都会先发起一次预检请求(options)
:octocat: From gitme Android
`const flyio = require("flyio"); //添加请求拦截器 flyio.interceptors.request.use((request) => { request.baseURL = baseURL; //给所有请求添加自定义header request.headers["X-Tag"] = "flyio"; request.url = request.url + "?beid=3";
//打印出请求体 console.log(request.body); //终止请求 return request; }); //添加响应拦截器,响应拦截器会在then/catch处理之前执行 flyio.interceptors.response.use( (response) => { Toast(response.data.status) if(response.data.status == 1){ return response.data.result } }, (err) => { console.log(err); //发生网络错误后会走到这里 //return Promise.resolve("ssss") } )
// get export const _get = (req) => { return flyio.get(req.url,req.data) }
// post export const _post = (req) => { return flyio.post(req.url, req.data) } `