Question
Define routes for server.js to help create part of a Web API using a pre-built dataService module with the given methods below (Note: each method
Define routes for server.js to help create part of a "Web API" using a pre-built dataService module with the given methods below (Note: each method returns a "promise" that resolves with data where appropriate).
getAllStudents() getStudentById(id) addStudent(studentObject) updateStudentById(id, studentObject); deleteStudentById(id)
For our routes, we simply need to work with the methods and return the data to the client we do not need to handle promise "rejections" (using "catch"):
a) Update a student (data sent in the body of the request) using the route "/api/students/id" (ie: api/students/579365473). When successful, return the JSON formatted object: {message:"Students' information with ID 579365473 has been updated"}
b) Add a new student (data sent in the body of the request) using the route "/api/students". When successful, return the JSON formatted object: {message: "New student has been created"}
c) Delete a student using the route "/api/students/id" (ie: /api/students/579365473). When successful, return the JSON formatted object: {message:"Student with ID 579365473 has been deleted"}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started