This is a template for a basic fullstack web using as exercise during the Full stack Web Development bootcamp of CoderSchool.vn
Build 2 endpoints for GET methods
- /students : return all student, allow search by age or name
- /students/:id : return single student with the match id
Using data from given db.json
file
Build a simple layout to display server response also UI for making search request.
-
Clone this codebase
-
check gitignore
-
npm i
-
Import data from
db.json
-
In
routes/index.js
, identify the callback ofroute.get("/students")
-
Ignore the commented code for now
-
Add a function that sending a list of all students
-
Uncommented the commented code, save and :
- Try on your browser : "http://localhost:5000/students?age=3"
- Check the console log
- Try on your browser : "http://localhost:5000/students?name=tuan"
- Check the console log
- Guess what was happening ? then
- Refactor the code so that when this route is called, it return a list of student that match accordingly to
name
orage
query. And also send a list of all students if there is no query eg "http://localhost:5000/students"
-
In
routes/index.js
, identify the callback ofruote.get("/students/:id")
-
Add a function that send back to client the correct info of the student id requested
-
Test on browser : "http://localhost:5000/students/(input an id here)" to see if we success
-
Create a simple front-end website HTML CSS and JS that using your newly created api to :
- Display a list of student, everylist is clickable
- Make an age search box to input age then make call to correct api endpoint
- Display a list of students that match the search in your UI of choice
- Make an name search box to input age then make call to correct api endpoint
- Display a list of students that match the search in your UI of choice
Bounus: Fullstack Web Application
- Turn every student listing into a clickable element
- When click , make a call to http://localhost:5000/students\studentIDofTheClicked"
- Display the result in your UI of choice
- Beautify your first Full-stack Web Application