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

  • Post author:
  • Post category:其他

post请求

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

get请求

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

版权声明:本文为qq_43225030原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。