Requests
HTTP methods
Choose GET, POST, PUT, PATCH, DELETE, HEAD, and OPTIONS according to the action a request asks the server to perform.
8 minute lesson
~~~
The method describes the request’s intent.
GETretrieves a resource.POSTsubmits data or starts an action.PUTreplaces a resource.PATCHupdates part of a resource.DELETEremoves a resource.HEADasks for the headers aGETwould return, without the body.OPTIONSasks which communication options are available.
For a notes API, you might use:
GET /notes
POST /notes
GET /notes/42
PATCH /notes/42
DELETE /notes/42
HTTP does not automatically enforce what a method means. A server could delete data in response to GET, but that would violate expectations and cause problems for caches, crawlers, and browsers.
Lesson completed