Today, I will visually represent how a REST API handles the Four main CRUD (Create, Read, Update, Delete) operations using HTTP methods. Here's a breakdown of each section:
➡️ 1. CRUD Operations
👉 Create : Represented by " POST " method. It's used to create new resources.
👉 Read : Represented by " GET " method. It's used to retrieve data from the server.
👉 Update : Represented by " PUT " method. It's used to update existing resources.
👉Delete : Represented by " DELETE " method. It's used to remove resources from the server.
➡️ 2. HTTP Methods
👉 POST : Sends data to the server in the request body to create a new resource.
🫵 Example: " /students " creates a new student entry.
➡️ GET : Fetches data from the server, either a single item using an ID (/students/:id) or a list of items (/students).
🫵 Example: " /students " gets a list of students; (/students/:id) gets a specific student.
➡️ PUT : Updates existing resources. Data is often found in the request body or URL parameters.
🫵 Example: " /students/:id " updates a specific student's data.
➡️ DELETE : Removes a resource identified by an ID from the server.
- Example: " /students/:id " deletes a specific student.
➡️3. Resource Endpoints
The endpoints are designed based on the resource (in this case, " students ").
👉 " /students " : Represents the collection of students.
👉 " /students/:id " : Refers to a specific student identified by an ID.
➡️4. Data Handling
🫵 POST and PUT : Send data in the request body.
👉 GET and DELETE : Use URL parameters to find specific resources, such as " :id " for identifying individual students.
➡️ 5. Flow
👉 Each operation (POST, GET, PUT, DELETE) corresponds to specific actions on the resource (" /students " or " /students/:id ").
🤖 The diagram shows the routing logic, where operations map to the appropriate HTTP method and endpoint.
I'm trying to simplify the understanding of how REST APIs operate by associating each HTTP method with common CRUD operations and endpoints.
May your journey be filled with learning, growth, and discoveries. Keep pushing boundaries, exploring new ideas, and coding your way to success. Wishing you endless inspiration and the strength to tackle any challenge that comes your way. Best of luck😍
Top comments (0)