http.js
const service = axios.create({
baseUrl: "//apixh-beta.17win.com", // window.xhHost["solar-api"], // "apixh-beta.17win.com",
timeout: 5000
})
service.interceptors.request.use(
config => {
//...
},
err => {
//...
}
)
// ...
export default service
api.js
import Http from "@/http"
export default {
getData (params) {
console.log("get my cert...")
return Http({url:"/api/XXX", method: "get", params})
}}
home.js
import Service from "@/api.js"
Service.getMyCert({}).then(response => {}) // request URL: http://localhost:3000/api/xxx
axios.create sets baseUrl, but the actual requested baseUrl is still localhost:3000/api/xxx