Pacharapol Withayasakpunt
Posted on March 11, 2020
It might be
- POST - Create NEW record
- PUT - If the record exists, update else, create a new record
- PATCH - update
- GET - read
- DELETE - delete
But, do you really ever use PUT requests?
Also, we have to consider which can have req.body
. To my understandings, GET and DELETE shouldn't have BODY, so mine becomes
- GET - Simple query, like
?id={id}
- POST - Complex query that needs
req.body
/ file upload - PUT - Create NEW record
- PATCH - Update
- DELETE - Delete
Another thing to consider, IDEMPOTENCY. Do I have care about it?
HTTP Idempotency
GET yes
POST no
PUT yes
PATCH no*
OPTIONS yes
HEAD yes
DELETE yes
Why can't we use POST for everything?
Also, don't forget that there are also HEAD and OPTIONS.
💖 💪 🙅 🚩
Pacharapol Withayasakpunt
Posted on March 11, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
javascript How do you split contenteditable text preserving html formatting? [solved]
August 11, 2019