This project demonstrates managing student data using API endpoints and a React-based frontend. It showcases the use of Axios for making HTTP requests and Express.js for creating a backend server.
- Endpoint:
GET /data/:id - Description: Retrieves the student details (name and marks) for a given student ID.
- Request Parameters:
id: The unique ID of the student.
- Response:
- Success (200):
{ "name": "Harsh", "marks": 95 } - Failure (404):
{ "error": "Data not found for the given ID" }
- Success (200):
- Endpoint:
POST /data/:id - Description: Adds a new student or updates an existing student's data.
- Request Parameters:
id: The unique ID of the student.
- Request Body:
{ "name": "krishna", "marks": 85 } - Response:
- Success (200):
{ "message": "Data added/updated successfully" } - Failure (400):
{ "error": "Invalid input data" }
- Success (200):
The frontend is built using React and allows the user to:
- Fetch student data by entering their ID and clicking the "Fetch Data" button.
- Add or update student data by providing their ID, name, and marks, and clicking the "Send Data" button.
- Frontend: React, Axios
- Backend: Express.js, Node.js
- Data Storage: JSON file
- Clone the repository.
- Install dependencies for both frontend and backend:
cd frontend npm install
cd ../backend npm install
- Start the backend server:
node server.js
- Start the frontend development server:
npm start
This project is open-source and can be freely used and modified.