fly
fly copied to clipboard
vue-cli使用flyio实现http请求返回的数据却是String类型?
` //http.js import Fly from 'flyio/dist/npm/fly' import config from '@/config'
const request = new Fly()
request.config = { baseURL: config.host, parseJson:true }
function getAuth () {
let headers = {}
headers['Content-Type'] = 'application/json'
return headers
}
//index.vue
let result = await Api.Data({})
console.log(result)
console.log(typeof result)
`
第一行是发出的请求, 第二行返回的data是字符串,我明明请求是application/json,,不知道是什么原因?
我也出现这个问题,在ios上ok,在android就会出现这个。自己JSON.parse一下吧
new的时候 { parseJson: true }