Commit 4be751b4 authored by lipengcheng 's avatar lipengcheng

fix: api管理中请求方法大小写bug

parent 90bcaf68
......@@ -19,18 +19,24 @@ const apiMap = {
login: { method: 'post', url: '/login' }
}
const requestMap = {}
Object.keys(apiMap).forEach((alias) => {
const { method, url, config } = apiMap[alias]
requestMap[alias] = (dataOrParams = {}, instanceConf = {}) => {
const keyName = ['PUT', 'POST', 'PATCH'].includes(method) ? 'data' : 'params'
return request({
method: method.toUpperCase(),
url,
[keyName]: dataOrParams,
...Object.assign(config || {}, instanceConf)
})
}
})
// const requestMap = {}
export default requestMap
function injectRequest(apiObj) {
const requestObj = {}
Object.keys(apiObj).forEach((alias) => {
let { method, url, config } = apiObj[alias]
method = method.toUpperCase()
requestObj[alias] = (dataOrParams = {}, instanceConf = {}) => {
const keyName = ['PUT', 'POST', 'PATCH'].includes(method) ? 'data' : 'params'
return request({
method,
url,
[keyName]: dataOrParams,
...Object.assign(config || {}, instanceConf)
})
}
})
return requestObj
}
export default injectRequest(apiMap)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment