Building Restful Apis With Express: // Build A Web Server
Building Restful Apis With Express: // Build A Web Server
// Creating a course
app.post(‘/api/courses’, (req, res) => {
// Create the course and return the course object
resn.send(course);
});
// Updating a course
app.put(‘/api/courses/:id’, (req, res) => {
// If course not found, return 404, otherwise update it
// and return the updated object.
});
// Deleting a course
app.delete(‘/api/courses/:id’, (req, res) => {
// If course not found, return 404, otherwise delete it
// and return the deleted object.
});
- You should never trust data sent by the client. Always validate! Use Joi package
to perform input validation.