From the course: React: Creating and Hosting a Full-Stack Site

Schalten Sie den kompletten Kurs noch heute frei

Join today to access over 23,400 courses taught by industry experts.

Rewriting your comments endpoint

Rewriting your comments endpoint

"

- [Instructor] All right, so now that we've converted our upvote endpoint over to use MongoDB, the last endpoint that we have to convert is our comments endpoint, so let's head back to our IDE and do that. All right, we're going to scroll down now to our post API/articles/:name/comments endpoint. And essentially, what we're going to need to do inside of here is the same thing that we did in our upvote endpoint. We're just going to need to change this part where we're saying articlesInfo.find, and we're going to need to change article.comments.push to an actual MongoDB query. And actually, as a matter of fact, I'm realizing now that we forgot to remove this article.upvotes plus equals one thing from above in our upvote endpoint. And that's actually why we were seeing one extra upvote on our articles. I thought it was just because I tested it beforehand, but apparently not. So anyway, let's head back down to our comments…

Inhalt