100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > axios get和post请求带参数和headers配置

axios get和post请求带参数和headers配置

时间:2019-02-03 00:23:50

相关推荐

axios get和post请求带参数和headers配置

get 方法1传入参数的时候,需要 { } 然后在里面传入 params 这个参数,一定要是params。

const id = 'xxx';const token = 'xxxxxxxxxxxxxxxxx';axios.get("http://xxx/xxx",{//参数列表params:{id :12345}, //请求头配置 headers:{ token: token}}).then((res)=>{console.log(res)}).catch((error)=>{console.log(error);})

post

const id = 'xxx';const token = 'xxxxxxxxxxxxxxxxx';axios.post("http://xxx/xxx",//参数列表{'id': id},//请求头配置 {headers: {'token':token }}).then((res)=>{console.log(res)})

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。