in the vue project, the get method of axios is used to request Kingsoft Ciba daily api
the status code returned is 200, and there is response data, as shown in figure
:
then the setting of dev in the index.js file:
proxyTable: {
"/api":{
target:"https://open.iciba.com/",
changeOrigin:true,
pathRewrite: {"^/api" : "/"}
}
},
then comes part of the code for the component Cart.vue:
// mounted axios
// request
this.$axios.interceptors.request.use((config)=>{
config.withCredentials = true;
console.log("request init...");
console.log(config)
config.headers={
"Content-Type":"application/x-www-form-urlencoded"
}
return config;
})
// response
this.$axios.interceptors.response.use((response)=>{
console.log("response init...");
console.log(response);
return response;
})
// axiosget
methods: {
get(){
var me = this;
var date = new Date();
var year = date.getFullYear() + "-";
var month = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() +1) + "-";
var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
var now = year+month+day;
me.$axios.get("/dsapi",{
params:{
date:now // --
}
}).then(res=>{
console.log(res)
})
},
}
what"s going on? the network of the browser can get the data, but it can"t get it. Find a solution
.