Join Shaun Wassell for an in-depth discussion in this video Adding comments, part of React: Creating and Hosting a Full-Stack Site.
- [Instructor] And that's going to look like this. … Just as in our up vote endpoint, … we're going to have to get the article name … from the URL parameters. … We'll just copy and paste this line. … Now, it's just a matter of adding the new comment … that's in the request body to the comments array … of the appropriate article in our fake database. … And that'll look like this. … We'll say articlesInfo, articleName, … again, this will get us the correct article info … from our fake database, … and then we'll say .comments.push, … and we'll add a new object that contains … the username and text properties from the request body. … And, finally, we're going to send back a response. … So we want to do res.status, … again, we want to send a status of 200 … to say that everything went okay, … .send, and then we want to send the appropriate article, … which will be articlesInfo, articleName. … Let's test this route now. … We've already got our request set up in Postman … with the correct endpoint and request body, …
- Creating the app component
- Using React-Router links
- Setting up an Express server
- Route parameters in Express
- Adding the comments functionality
- Installing and adding MongoDB to your project
- Rewriting the endpoints
- Adding React hooks
- Adding buttons and forms
- Pushing code to GitHub
- Running a full-stack app on AWS
Skill Level Intermediate
1. Creating a React Front End
2. Creating a Node Back End
3. Setting Up MongoDB
4. Connecting the Front and Back Ends
5. Hosting the Site
Next steps1m 17s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.