一、post四种
/` 参数为query string parameters,接口数据格式要求为raw时 `/
export const postJson = (url, params) => { return service({ method: 'post', url: `${url}`, data: JSON.stringify(params), headers: { 'Content-Type': 'application/json' } }) }
/` 参数为query string parameters,接口数据格式要求为x-www-form-urlencoded时 `/
export const post = (url, params, tout = 20000) => {
return service({ method: 'post', url: url, data: params, timeout: tout, headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, transformRequest: [ function(data) { return qs.stringify(data) } ] }) }
/` 上传文件,接口数据格式要求为form-data时 `/
export const uploadFile = (url, params) => {
return service({
method: 'post',
url: `${url}`,
data: params,
headers: {
'Content-Type': 'multipart/form-data'
}
})
}
/` 参数为query string parameters,接口数据格式要求为x-www-form-urlencoded时,获取文件二进制流 `/
export const getExport = (url, params, tout = 999999) => {
return service({
method: 'post',
url: `${url}`,
data: params,
timeout: tout,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
transformRequest: [
function(data) {
return qs.stringify(data)
}
],
responseType: 'blob'
})
}
ps: 待更新