liveBook · Manning

HTTP method

As explained in Pro Angular 16

An HTTP method is a standardized operation verb in HTTP that specifies the intended action for a request.

An HTTP method, also called a verb, tells a RESTful web service which operation to perform. The request URL identifies the collection or object affected, so the method and URL work together to express the request. section 23.2

Common method-and-URL combinations include:

  • GET /products retrieves every object in the products collection. section 23.2
  • GET /products/2 retrieves the object whose identifier is 2. section 23.2
  • POST /products adds a new object, supplied as JSON in the request body. section 23.2
  • PUT /products/2 replaces the selected object, while PATCH /products/2 updates only selected properties. section 23.2
  • DELETE /products/2 removes the selected object. section 23.2

Selecting a product

A browser request to http://localhost:3500/products/2 uses GET by default. The URL selects the products collection item with identifier 2, and the server returns its JSON representation, such as the Lifejacket product. section 23.2

Table 23.3. Common HTTP verbs and their effect in a RESTful web service
Verb
URL
Description
GET
/products
This combination retrieves all the objects in the products collection.
GET
/products/2
This combination retrieves the object whose id is 2 from the products collection.
POST
/products
This combination is used to add a new object to the products collection. The request body contains a JSON representation of the new object.
PUT
/products/2
This combination is used to replace the object in the products collection whose id is 2. The request body contains a JSON representation of the replacement object.
PATCH
/products/2
This combination is used to update a subset of the properties of the object in the products collection whose id is 2. The request body contains a JSON representation of the properties to update and the new values.
DELETE
/products/2
This combination is used to delete the product whose id is 2 from the products collection.

Use the method-and-URL table to compare retrieval, creation, replacement, partial updates, and deletion. section 23.2

How Pro Angular 16 covers it

How deep it goes
Defines common method-and-URL combinations and cautions that services may vary in verb, URL, and request-body requirements.
Examples
Uses product collection requests, including GET /products/2, and middleware mappings that protect selected GET and POST endpoints.
What you can do after
Apply it via RESTful URLs and Angular HttpClient methods to retrieve, create, replace, update, or delete web-service data.
How it connects
Connects HTTP methods with RESTful web services, URLs, request bodies, Angular HttpClient, observables, and CORS.

Also explained in

Compare how 10 books explain HTTP method →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro Angular 16. The section links point to the parts of the book it draws on.