PATCH
This tutorial shows you how to update an existing task using the PATCH
method of the To-Do API. This is helpful when you want to update just one or two fields of a task — like marking it complete or changing the title — without sending the entire object.
Update an existing task’s title
or completed
status using the PATCH
/tasks/{taskId}
endpoint.
Before you begin, make sure you have:
localhost:3000
curl
or Postmancurl
curl -X PATCH http://localhost:3000/tasks/1 \
-H "Content-Type: application/json" \
-d "{\"completed\": true}"
### Expected Response
```json
{
"id": 1,
"title": "Sample Task",
"completed": true
}
PATCH
method.http://localhost:3000/tasks/1
Content-Type
application/json
raw
, and choose JSON
as the format.{
"title": "Updated Task Title"
}
###Expected Response
{
"id": 1,
"title": "Updated Task Title",
"completed": false
}