34 lines
787 B
JavaScript
34 lines
787 B
JavaScript
import axios from "axios";
|
|
|
|
const instance = axios.create({
|
|
baseURL: 'https://www.gitlink.org.cn', // 你的API基础URL
|
|
timeout: 20000, // 请求超时时间
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
});
|
|
|
|
// 封装GET请求
|
|
function get(url, params) {
|
|
return instance.get(url, { params }).then(response => response.data);
|
|
}
|
|
|
|
// 封装POST请求
|
|
function post(url, data) {
|
|
return instance.post(url, data).then(response => response.data);
|
|
}
|
|
|
|
// 封装PUT请求
|
|
function put(url, data) {
|
|
return instance.put(url, data).then(response => response.data);
|
|
}
|
|
|
|
// 封装DELETE请求
|
|
function deleteRequest(url) {
|
|
return instance.delete(url).then(response => response.data);
|
|
}
|
|
|
|
export const getPathType = (pathname) => {
|
|
return get(`/api/owners/${pathname}.json`)
|
|
}
|