课程: React: Creating and Hosting a Full-Stack Site (2022)
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Adding comments
- [Instructor] All right, so now that we've got our server working fairly well and we've implemented upvote functionality and made it restart automatically, the next thing that we're going to do is add the ability for users to add comments to articles to our server. Okay, so the first thing that we're going to want to do here before we create a new endpoint for adding comments to articles is we're going to go up here to our articles info in-memory fake database thing and we're going to add another property to each of these that will store the comments for each article. So what we're going to do is we're just going to add a comments property to each of these, and the starting value for this is going to be an empty array. Now, what we're going to do is inside the endpoint that we create for adding comments, we're basically just going to take any information that we get from the user, such as the comment text and create a…