- Clone the repository:
git clone https://github.com/gubbysbyte/to-do-list
cd simple-todo-api-
Install dependencies:
npm install
To start the server, run the following command. It will be accessible at http://localhost:3000.
node index.js- Method:
GET - Endpoint:
/todos - Description: Retrieves a list of all to-do items.
- Success Response (200 OK):
[ { "id": 1, "task": "Learn Node.js", "completed": false }, { "id": 2, "task": "Build a Simple API", "completed": true } ]
- Method:
GET - Endpoint:
/todos/:id - Description: Retrieves a single to-do item by its ID.
- Success Response (200 OK):
{ "id": 1, "task": "Learn Node.js", "completed": false }
- Method:
POST - Endpoint:
/todos - Description: Creates a new to-do item.
- Request Body:
{ "task": "Deploy the application" } - Success Response (201 Created):
{ "id": 4, "task": "Deploy the application", "completed": false }
- Method:
PUT - Endpoint:
/todos/:id - Description: Updates an existing to-do item's task or completion status.
- Request Body:
{ "task": "Learn Express.js middleware", "completed": true } - Success Response (200 OK):
{ "id": 1, "task": "Learn Express.js middleware", "completed": true }
- Method:
DELETE - Endpoint:
/todos/:id - Description: Deletes a to-do item by its ID.
- Success Response (204 No Content): No body content is returned.