import axios from “axios”;
export default {
//get方法
get: function (path = '', data = {}) {
return new Promise(function (resolve, reject) {
axios.get(path, {
params: data,
})
.then(function (response) {
resolve(response);
})
.catch(function (error) {
reject(error);
});
});
},
//通常的post方法,使用data传参
post: function (path = '', data = {}) {
return new Promise(function (resolve, reject) {
axios.post(path, {
data
})
.then(function (response) {
resolve(response);
})
.catch(function (error) {
reject(error);
});
});
},
//post请求使用params传参
ParamsPost: function (path = '', params = {}) {
return new Promise(function (resolve, reject) {
axios.post(path, null, {
params
})
.then(function (response) {
resolve(response);
})
.catch(function (error) {
reject(error);
});
});
},