接口
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import axios from "axios";
|
||||
import requestURL from './url';
|
||||
let token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWRlbnRpZmllciI6ImU5Y2EyM2Q2OGQ4ODRkNGViYjE5ZDA3ODg5NzI3ZGFlIiwiZXhwIjoxNzAyMDA1MDQ4fQ.M1Xlecj3eUOgZUSofOlyBMoxJ5F01KH-tgJxaV2Femc\n'
|
||||
const service = axios.create({
|
||||
baseURL: requestURL,
|
||||
timeout: 50000,
|
||||
headers: {
|
||||
// 设置后端需要的传参类型
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
'X-Access-Token':token
|
||||
}
|
||||
})
|
||||
export const get = (url, params) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
service.get(url, {params: params}).then(res => {
|
||||
if (res.data.code === 200) {
|
||||
resolve(res.data);
|
||||
} else {
|
||||
reject(res.data);
|
||||
}
|
||||
}).catch(err => {
|
||||
reject(err.data);
|
||||
})
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user