/ / axios.js
import axios from "axios"
import qs from "qs"
const service = axios.create({
baseURL: "//askpre.hishixi.cn/api",
timeout: 15000,
transformRequest: [function (data) {
data = qs.stringify({});
return data;
}]
})
service.defaults.withCredentials = true
// POST
service.interceptors.request.use((config) => {
return config
}, (error) => {
return Promise.reject(error)
})
//
service.interceptors.response.use(function (res) {
return res.data
}, function (error) {
return Promise.reject(error)
})
export default service
/ / component
import axios from "../plugins/axios.js"
axios.post("abc", {
page: 1
})