0% found this document useful (0 votes)
13 views4 pages

API Task (Cla)

The document outlines the steps to build a RESTful API using Express.js for managing a Todo List with full CRUD operations. It includes detailed instructions for setting up the project environment, installing necessary tools like Node.js and Postman, and creating a basic server with example code. The API will handle Todo items, each containing an ID, title, and description.

Uploaded by

kattujadal
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views4 pages

API Task (Cla)

The document outlines the steps to build a RESTful API using Express.js for managing a Todo List with full CRUD operations. It includes detailed instructions for setting up the project environment, installing necessary tools like Node.js and Postman, and creating a basic server with example code. The API will handle Todo items, each containing an ID, title, and description.

Uploaded by

kattujadal
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Task : Build a RESTful API Using Express.

js

Developing a RESTful API for Managing a Todo List

Design and implement a RESTful API using [Link] that allows users to perform full
CRUD (Create, Read, Update, Delete) operations on a single resource — a Todo item.

Task Description:

You are required to build a RESTful API that manages a Todo List.

Each Todo item should contain:

{
"id": 1,
"title": "Assignment-2",
"description": "Finish Express API task",

Detailed Instructions to Complete the Task


Step 1: Postman Tool Installation

Before commiting to project you please Install POSTMAN


Tool in your System
[Link]

The Above link having the detailed instruction to install postman Tool

Step 2: Project Setup

1. Install [Link] -- > ( Install the latest version through Google Chrome)
2. Create a new project folder: -- > (Create a Empty folder in your VS Code)

Execute the below commands in your vs code Terminal:

mkdir todo-api
cd todo-api

3. Initialize a Node project:


Execute the below comment in vs code terminal
npm init -y

4. Install Express: -- > (Exceute the below one in Your Vs code Terminal)

npm install express

5. Create a file named: -- > (Create the file in your folder with [Link])

[Link]

Step 2: Basic Server Setup

In [Link]:

 Import Express
 Create an Express app
 Enable JSON middleware
 Set the server to run on port 3000

Example structure: -- > (The below code is example code just execute for
testing the environment)

const express = require('express');

const app = express();

const PORT = 3000;

// Middleware to parse JSON

[Link]([Link]());

// Simple GET route

[Link]('/', (req, res) => {


[Link]('Server is running successfully!');

});

// POST route example

[Link]('/student', (req, res) => {

const { name, branch } = [Link];

[Link]({

message: 'Student data received successfully',

data: {

name,

branch

});

});

// Start server

[Link](PORT, () => {

[Link](`Server running on [Link]

});

Run the server in your vs code

[Link]
After that open your Postman Tool and place the [Link](output)

Example: Localhost:8090(or something you get after excuting


[Link])

You place that(Localhost:8090) or something that you get for testing the
APIS (GET,POST) Methods in Postman .

You might also like