import axios from "axios";
// 封装
axiosexport function get(url, params = {}, headers = {}, option = {}) {
return new Promise((resolve, reject) => {
axios({
url: url,
method: "GET",
headers,
data: params,
...option
}).then(
response => {
if (response) {
resolve(response.data);
}
},
err => {
reject(err);
}
);
});
}
export function post(url, params = {}, headers = {}, option = {}) {
return new Promise((resolve, reject) => {
axios({
url: url,
method: "POST",
headers,
data: params,
...option
}).then(
response => {
if (response) {
resolve(response.data);
}
},
err => {
reject(err);
}
);
});
}
由于代码中调用接口一写就一大推 所以进行封装 调用如下
import { adminSer } from "@/public/env-conf";
import {post,get} from "./axios";
export const contractApi = {
contractAudit: (p) => post(`${adminSer}/audit/contractAudit`, p),
};