axios基本请求格式 POST、GET

设置global的axios参数

##axios 
axios.defaults.baseURL = 'http://localhost:7001/micro';
axios.defaults.headers.common['school_id'] = "1005";
axios.defaults.headers.post['content-Type'] = 'application/json;charset=UTF-8';   //post参数传递的json形式

1.GET请求

//params:{"page_size":3},此参数会拼接到url上,最后形式为:/items?page_size=3
axios.get("/items",{params:{"page_size":3}}).then(res=>{   
                console.log(res);
            }).catch(err=>{
                console.log(err);
            })

2.POST请求

//{"is_show": 0, "name": "尽力金", "type": 0} 是以json的形式传输的
axios.post("/item",
    {"is_show": 0, "name": "尽力金", "type": 0}
).then(res=>{
    console.log(res);
}).catch(err=>{
    console.log(err);
})

 github上有我更多的笔记:Raray-chuan (兮川) · GitHub,欢迎stars与following,如果有问题可以在issue中向我咨询

关注我的公众号,获取更多关于后端、大数据的知识

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值