简体   繁体   English

Axios /表达GET / POST / PUT / DELETE

[英]Axios/express GET/POST/PUT/DELETE

In express router and Axios (and many other frameworks/APIs), you can use GET/POST/PUT/DELETE. 在快速路由器和Axios(以及许多其他框架/ API)中,可以使用GET / POST / PUT / DELETE。

Why do you specify these, what are the differences? 为什么要指定这些,有什么区别?

I understand that a GET is used the get the data, and a POST to post the data. 我了解使用GET来获取数据,并使用POST来发布数据。

But even if you use an Axios.post to get data it works just fine if you set up the API endpoint to send the data back. 但是,即使您使用Axios.post来获取数据,如果您设置API端点以将数据发送回去,它也可以正常工作。

Is there any technical differences or is it just out of good practice and readability. 是否存在任何技术差异,或者仅仅是出于良好的实践和可读性。

It is possible to use HTTP methods in a "non-traditional" way, according to your example, this works. 根据您的示例,可以以“非传统”方式使用HTTP方法。 However, it is not a good practice to use them like this, it is best to follow the good practices and constraints of REST 但是,这样使用它们不是一个好习惯,最好遵循REST的好习惯和约束

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM