MCPcopy Create free account
hub / github.com/bailicangdu/react-pxq / axios

Method axios

src/api/server.js:19–47  ·  view source on GitHub ↗
(method, url, params)

Source from the content-addressed store, hash-verified

17
18export default class Server {
19 axios(method, url, params){
20 return new Promise((resolve, reject) => {
21 if(typeof params !== 'object') params = {};
22 let _option = params;
23 _option = {
24 method,
25 url,
26 baseURL: envconfig.baseURL,
27 timeout: 30000,
28 params: null,
29 data: null,
30 headers: null,
31 withCredentials: true, //是否携带cookies发起请求
32 validateStatus:(status)=>{
33 return status >= 200 && status < 300;
34 },
35 ...params,
36 }
37 axios.request(_option).then(res => {
38 resolve(typeof res.data === 'object' ? res.data : JSON.parse(res.data))
39 },error => {
40 if(error.response){
41 reject(error.response.data)
42 }else{
43 reject(error)
44 }
45 })
46 })
47 }
48}

Callers 5

uploadImgMethod · 0.80
getRecordMethod · 0.80
getProductionMethod · 0.80
getBalanceMethod · 0.80
main.83dc4a4d.jsFile · 0.80

Calls 1

resolveFunction · 0.50

Tested by

no test coverage detected