zhangxiaoxu123
2022-07-14 8c2bdac410ae06761c997d534883bd845237c33f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import {
    fetch
} from './request.js';
 
const typeObj = {
    headerGET: {
        "Content-type": 'application/x-www-from-urlencoded'
    },
    headerPOST: {
        "Content-type":'application/json'
        // 'Content-Type': 'application/x-www-form-urlencoded',
        
    },
}
 
// 通用接口请求
export const reqAll = (url, params, opt = {}) => {
    opt.data = params;
    opt.header = typeObj['headerPOST'];
    return fetch(url, opt)
}
 
// get请求
export const reqGet = (url, params, opt = {}) => {
    opt.header = typeObj['headerGET'];
    opt.method = "GET";
    opt.data = params;
    return fetch(url, opt)
}
 
// post请求
export const reqPost = (url, params, opt = {}) => {
    opt.header = typeObj['headerPOST'];
    opt.method = "POST";
    opt.data = params;
    return fetch(url, opt)
}