封装:
var posting = function (
url,
data,
contentType = "application/x-www-form-urlencoded"
) {
console.log(data);
return new Promise((resolve, reject) => {
axios
.post(url, data, { headers: { "Content-Type": contentType } })
.then((res) => {
resolve(res);
})
.catch((err) => {
reject(err);
});
});
}; //单独为request.body起的,不要qs
使用:
import http from "@/request/axios";
getData(params) {
http
.posting(
"/boss/bsActivities/getActivitiesB2List",
params,
"application/json"
)
.then((res) => {
console.log(res);
if (res.data.code == 1) {
this.$message.success("编辑成功");
this.getallList();
}
});
},