feat:增加api接口文件配置

This commit is contained in:
wuyx
2022-10-21 16:42:30 +08:00
parent e26dc49e56
commit fdcc7de35d
4 changed files with 127 additions and 8 deletions

8
src/api/config.js Normal file
View File

@@ -0,0 +1,8 @@
import axios from "axios";
const http = axios.create({
baseURL: 'http://localhost:8082/api',
timeout: 1000 * 100
});
export default http;

20
src/api/index.js Normal file
View File

@@ -0,0 +1,20 @@
import http from "./config";
// 接口
export const getUserInfo = () => http.get('/');
export const getUserById = (x, y, z) => http.post('/getuserbyid', { x, y, z });
// 使用方法
// import * as api from '../../api/index'
// api.getUserById(6, 7, 8).then(res => {
// console.log(res)
// }).catch(err => {
// console.log(err)
// })
// api.getUserInfo().then(res => {
// console.log(res)
// }).catch(err => {
// console.log(err)
// })