金币系统前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

26 lines
646 B

import request from './request'
export default function requestHandler(options) {
const { method = 'get', url, data = {}, params = {}, headers = {} } = options
return request({
method,
url,
data,
params,
headers
})
.then(({ status, data, statusText }) => {
if (status === 200) {
return data
} else {
throw new Error(statusText)
}
})
.catch(error => {
if (error?.needsLogin) {
return { needsLogin: true }
}
return Promise.reject(error)
})
}