April 2020
Intermediate to advanced
716 pages
18h 55m
English
To implement the Newsfeed-specific API, we need to add the route endpoint that will receive the request for Newsfeed posts and respond accordingly to the requesting client- side.
On the backend, we need to define the route path that will receive the request for retrieving Newsfeed posts for a specific user, as shown in the following code.
server/routes/post.routes.js
router.route('/api/posts/feed/:userId') .get(authCtrl.requireSignin, postCtrl.listNewsFeed)
We are using the :userID parameter in this route to specify the currently signed-in user. We will utilize the userByID controller method in user.controller to fetch the user details, as we did previously, and append these to the request object that is accessed in ...
Read now
Unlock full access