axios常用的四个方法:
- get:查询数据
- post:添加数据
- put:修改数据
- delete:删除数据
1.get传递参数
①通过URL传递参数
第一种:通过问号进行传参
axios.get('http://localhost:3000/axios?id=123').then(function(ret){
console.log(ret.data)
})
获取参数用query.id
app.get('/axios', (req, res) => {
res.send('axios get 传递参数' + req.query.id)
})
第二种:直接加参数进行传参
axios.get('http://localhost:3000/axios/123').then(function(ret){
console.log(ret.data)
获取参数用params.id
app.get(</