Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _id : 5c5b450918cb2b121648ff7a
- name : "dannondarko"
- email : "dangilmail@gmail.com"
- password : "$2a$10$3z5m1e9Pcfid72Q2GchCjeTD55/SsIxmtWr3I1ZiA.DX/KlpfTbdK"
- date : 2019-02-06 20:35:21.973
- __v : 0
- posts : Array
- 0 : Object
- note : "test for the user dannondarko"
- date : "02/08/2019"
- app.get('/:username', (req, res) => {
- username = req.params.username.toLowerCase();
- const collection = req.app.locals.collection;
- collection.find({ name: username }).toArray(function (err, results) {
- if (err) {
- res.status(500).send("Error communicating with the DB.");
- } else if (results.length > 0) {
- console.log("Here are the results: " + results);
- console.log({people: results});
- res.status(200).render('profile', {posts: results, name: username});
- } else {
- next();
- }
- });
- });
- <h1 class="mt-4"><%= name %></h1>
- <div class="container">
- <br>
- <% for(var i=0; i < posts.length; i++) { %>
- <div class="container">
- <label><%= posts[i].note %></label>
- <div class="container">
- <label><%= posts[i].date %></label>
- </div>
- </div>
- <% } %>
- </div>
Add Comment
Please, Sign In to add comment