While fetching data (GET) is read-only, modifying server data is called a mutation:
POST: Creates a new resource (e.g. enrolling in a course, submitting a review).PUT / PATCH: Updates an existing resource (PUT replaces; PATCH modifies specific fields).DELETE: Removes an existing resource from the server.Mutations are triggered by explicit user interactions (button clicks, form submissions). Unlike GET requests, mutations belong in event handlers, NOT in useEffect!
When sending data to a backend REST API:
method: 'POST'.'Content-Type': 'application/json' in the headers object.JSON.stringify(payload).When deleting a resource:
disabled={isSubmitting}) critical during network mutations?PUT and PATCH?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Fetching REST APIs with Async Await and State | Introduction to TanStack Query for Server State |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.
Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.