axios请求方式

https://www.cnblogs.com/daowangzhizhu-pt/p/6858925.html

 

"Content-Type": "application/json"// 顺便一提

"Content-Type": "application/x-www-form-urlencoded" // 适用于大部分情况

"Content-Type": "multipart/form-data" // 适用于文件上传

 

get 参数设置为params

post 放在body里面设置为data

 

// export let _SendPost=(type,url,params,cb) => {
// if (value.postfix === '.json' && type.toUpperCase() === 'POST') type = 'GET';
// return axios.post(value.prefix + url + value.postfix, JSON.stringify(params), {
// headers: {
// 'Content-Type': 'application/json;charset=UTF-8',
// }
// }).then(response => {
// if(response&&response.message=="Success"){
// cb(response)
// }else{
// cb(null)
// }
// }
// ).catch(err => {
// console.log(err)
// })
// }

export let _SendPost=(type,url,params,cb) => {
if (valueRes.postfix === '.json' && type.toUpperCase() === 'POST') type = 'GET';
return axios({
method: 'POST',
url: value.prefix + url + value.postfix,
data:{
...params
},
headers: {
'Content-Type': 'application/json;charset=UTF-8',
}
})
}
posted @ 2018-02-09 16:37  小曦曦  阅读(1210)  评论(0编辑  收藏  举报