Skip to Content
Full-Stack React Projects - Second Edition
book

Full-Stack React Projects - Second Edition

by Shama Hoque
April 2020
Intermediate to advanced
716 pages
18h 55m
English
Packt Publishing
Content preview from Full-Stack React Projects - Second Edition

The list of enrollments API

The list of enrollments API will take a GET request and query the Enrollments collection in order to find enrollments that have a student reference that matches with the user who is currently signed in. To implement this API, we will first declare the GET route for '/api/enrollment/enrolled', as shown in the following code:

mern-classroom/server/routes/enrollment.routes.js

router.route('/api/enrollment/enrolled')  .get(authCtrl.requireSignin, enrollmentCtrl.listEnrolled)

A GET request to this route will invoke the listEnrolled controller method, which will query the database and return the results in the response to the client. The listEnrolled method is defined as follows:

mern-classroom/server/controllers/enrollment.controller.js ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Full-Stack React Projects

Full-Stack React Projects

Shama Hoque
React Native - The Practical Guide

React Native - The Practical Guide

Academind by Maximilian Schwarzmüller GmbH

Publisher Resources

ISBN: 9781839215414Supplemental Content