import axios from 'axios'
import Qs from 'qs'
//axios的get方法中使用params时对于js数组类型的参数的默认操作比较诡异,会使得参数名后带上'[]'字符串,可以使用qs自带的 arrayFormat 参数配置解决这个问题
export function request(config) {
const service = axios.create({
headers: {'content-type': 'application/json'},
// baseURL: process.env.Vue,
// baseURL: 'https://api.apiopen.top/', // url = base url + request url
// baseURL: 'http://127.0.0.1:5000/',
timeout: 60000,
withCredentials: false,
paramsSerializer: params => {
return Qs.stringify(params, {arrayFormat: 'repeat'})
}
})
return service(config)
}