my axios function:
import axios from "axios"
import Qs from" qs"
export default {
post: function (url, data) {
axios.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded";
let config = {
//axios.get(url,config);urlconfigurl
url: url,
//
method: "post", // default
// url
baseURL: "https://39.104.91.74:8080/",
transformRequest: [function (data) {
// form-dataQsaxios
data = Qs.stringify({});
return data;
console.log(data)
}],
transformResponse: [function (data) {
//
return data;
}],
//
headers: {
"Authorization": sessionStorage.obj,
"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"
},
//parameter
params: {
timestamp: Date.parse(new Date()) / 1000
},
withCredentials:true,
//postaxios.post(url,{},config);
data: data,
//
timeout: 5000,
//
responseType: "json", // default
}
return axios.post(url, data, this.config)
}
}
call the interface on the page:
selectpriceDate = () = > {
let url="api/notice/list"
let form={
pageNo: "1",
pageSize: "12",
type:null
}
ajax.post(url, form)
.then(function (res) {
console.log(res)
})
.catch(function (err) {
console.log(err)
})
}
: