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 upvote endpoint

Rewriting your upvote endpoint

"

- All right, so now that we've created this endpoint for loading article info from MongoDB, the next thing that we're going to need to do is go through and modify our up voting endpoint and our comments endpoint to use MongoDB instead of that fake in-memory database which they're currently referencing that no longer exists, right? So this is actually going to be pretty straightforward. All we're really going to need to do is replace this line where we say articles info dot find with an actual query to MongoDB. Now, the setup code here, right? The code for connecting to MongoDB is going to be pretty much the same as what we saw up here in our get article endpoint. So just to go through that again, what we're going to need to do is use Mongo client to connect to MongoDB. And that's going to look like this. We'll say "const client equals new Mongo client" and then we'll have the URL, which again is going to be "MongoDB…

Inhalt