feat:http数据集请求体脚本优化

main
liu.shiyi 2 years ago
parent adbe605194
commit 6935cb24d1

@ -7,7 +7,7 @@ export default function axiosFormatting (customConfig) {
const httpConfig = { const httpConfig = {
timeout: 1000 * 30, timeout: 1000 * 30,
baseURL: '', baseURL: '',
headers: newCustomConfig.headers headers: { 'Content-Type': 'application/json', ...newCustomConfig.headers }
} }
// let loadingInstance = null // 加载全局的loading // let loadingInstance = null // 加载全局的loading
const instance = axios.create(httpConfig) const instance = axios.create(httpConfig)
@ -47,7 +47,7 @@ export default function axiosFormatting (customConfig) {
} }
}) })
const body = newCustomConfig?.body.replace(/: ,/g, ':undefined,').replace(/, }/g, ',undefined}') const body = newCustomConfig?.body.replace(/: ,/g, ':undefined,').replace(/, }/g, ',undefined}')
console.log('body', body) /** 发送请求 **/
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
instance({ instance({
method: newCustomConfig.method, method: newCustomConfig.method,
@ -61,22 +61,6 @@ export default function axiosFormatting (customConfig) {
}) })
}) })
} }
// function stringToObject (inputString) {
// const lines = inputString.split('\n')
// const result = {}
//
// lines.forEach(line => {
// // Use regular expressions to extract property name and value
// const propertyMatch = line.match(/^(.*?)=(.*)$/)
// if (propertyMatch) {
// const propertyName = propertyMatch[1].trim()
// const propertyValue = propertyMatch[2].trim().replace(/'/g, '') // Remove single quotes from the value
// result[propertyName] = propertyValue
// }
// })
//
// return { body: result }
// }
// 动态替换url后面参数的值 // 动态替换url后面参数的值
function replaceUrlParam (url, paramName, paramValue) { function replaceUrlParam (url, paramName, paramValue) {
const regex = new RegExp(`([?&])${paramName}=.*?(&|$)`, 'i') const regex = new RegExp(`([?&])${paramName}=.*?(&|$)`, 'i')

Loading…
Cancel
Save