Commit 15fca70e authored by lipengcheng 's avatar lipengcheng

feat: promise封装

parent 228e732a
Pipeline #3098 failed with stages
in 0 seconds
......@@ -31,12 +31,16 @@ function injectRequest(apiObj, axios) {
method = method.toUpperCase()
requestMap[alias] = (dataOrParams = {}, instanceConf = {}) => {
const keyName = ['PUT', 'POST', 'PATCH'].includes(method) ? 'data' : 'params'
return axios({
method,
url,
// [keyName]: method === 'POST' ? qs.stringify(dataOrParams) : dataOrParams,
[keyName]: dataOrParams,
...Object.assign(config || {}, instanceConf)
return new Promise((resolve, reject) => {
axios({
method,
url,
// [keyName]: methods === 'POST' ? qs.stringify(dataOrParams) : dataOrParams,
[keyName]: dataOrParams,
...Object.assign(config || {}, instanceConf)
})
.then((res) => resolve(res.data))
.catch((err) => reject(err))
})
}
})
......
import axios from 'axios'
import utils from 'axios/lib/utils'
import setConfig from '@/plugins/axios/axios.setConfig.js'
import handleResponse from '@/plugins/axios/axios.handleResponse.js'
import handleError from '@/plugins/axios/axios.handleError.js'
console.log('utils.merge:', utils.merge)
// import store from '@/store/index'
// import router from '@/router/index.js'
// import { Message } from 'element-ui'
......
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