April 2020
Intermediate to advanced
716 pages
18h 55m
English
The enrollment stats can be retrieved from the backend and rendered in the Course view, as shown in the following image:

To retrieve these enrollment stats, we will add a second useEffect hook in the Course component in order to make a fetch call to the enrollment stats API, as shown in the following code:
mern-classroom/client/course/Course.js
useEffect(() => { const abortController = new AbortController() const signal = abortController.signal enrollmentStats({courseId: match.params.courseId}, {t:jwt.token}, signal).then((data) => { if (data.error) { setValues({...values, error: data.error}) ...