import $axios from 'axios';
$axios.defaults.timeout = 5000;
$axios.defaults.baseURL = "http://127.0.0.1:8888/api";
$axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
$axios.interceptors.request.use(config => {
let token = sessionStorage.getItem("token");
if (token) {
config.headers.token = token;
}
return config;
})
export const get = (url, data) => {
return new Promise((resolve, reject) => {
$axios.get(url, {params: data}).then(data => {
resolve(data.data);
}).catch(err => {
reject(err)
})
})
}
export const post = (url, data = null) => {
return new Promise((resolve, reject) => {
$axios.get(url, data).then(data => {
resolve(data.data);
}).catch(err => {
reject(err)
})
})
}