get post get delete 四种请求方式(区别以及使用方式)
get请求方式
GET请求会向数据库发索取数据的请求,从而来获取信息,该请求就像数据库的select操作一样,只是用来查询一下数据,不会修改、增加数据,不会影响资源的内容,即该请求不会产生副作用。无论进行多少次操作,结果都是一样的。
服务器
// 传统的URL
app.get('/axios', (req, res) => {res.send('axios get 传递参数' + req.query.id)
})
// Restful 的URL
app.get('/axios/:id', (req, res) => {res.send('axios get(Restful) 传递参数' + req.params.id)
})
app.get('/data', (req, res) => {res.send('Hello World !')
})
客户端
axios.get('http://localhost:3000/adata').then(function (ret) {console.log(ret.data);});// 传统URL 只需要axios.get('http://localhost:3000/axios?id=123').then(function (res) {console.log(res.data);});axios.get('http://localhost:3000/axios/123').then
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
