feat:优化http数据集响应拦截处理

main
liu.shiyi 2 years ago
parent b329e10274
commit 9c9f3297e9

@ -35,8 +35,10 @@ export default function axiosFormatting (customConfig) {
instance.interceptors.response.use(response => {
if (response.data.code === 200) {
// 执行响应脚本
const resp = _.cloneDeep(response.data)
eval(newCustomConfig.responseScript)
// eslint-disable-next-line no-new-func
const getResp = new Function('response', newCustomConfig.responseScript)
const resp = getResp(response)
console.log(resp)
return Promise.resolve(resp)
} else {
Message({
@ -76,7 +78,7 @@ function replaceUrlParam (url, paramName, paramValue) {
}
// 将参数的值替换掉其他配置中对应属性的值
function replaceParams (customConfig) {
let newConfig = _.cloneDeep(customConfig)
const newConfig = _.cloneDeep(customConfig)
newConfig.url = evalStrFunc(newConfig.paramsList, newConfig.url)
newConfig.headers = evalArrFunc(newConfig.paramsList, newConfig.headers)
newConfig.params = evalArrFunc(newConfig.paramsList, newConfig.params)

Loading…
Cancel
Save