Guest User

Untitled

a guest
Feb 9th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. _id : 5c5b450918cb2b121648ff7a
  2. name : "dannondarko"
  3. password : "$2a$10$3z5m1e9Pcfid72Q2GchCjeTD55/SsIxmtWr3I1ZiA.DX/KlpfTbdK"
  4. date : 2019-02-06 20:35:21.973
  5. __v : 0
  6. posts : Array
  7. 0 : Object
  8. note : "test for the user dannondarko"
  9. date : "02/08/2019"
  10.  
  11. app.get('/:username', (req, res) => {
  12. username = req.params.username.toLowerCase();
  13. const collection = req.app.locals.collection;
  14.  
  15. collection.find({ name: username }).toArray(function (err, results) {
  16. if (err) {
  17. res.status(500).send("Error communicating with the DB.");
  18. } else if (results.length > 0) {
  19. console.log("Here are the results: " + results);
  20. console.log({people: results});
  21. res.status(200).render('profile', {posts: results, name: username});
  22. } else {
  23. next();
  24. }
  25. });
  26. });
  27.  
  28. <h1 class="mt-4"><%= name %></h1>
  29. <div class="container">
  30. <br>
  31. <% for(var i=0; i < posts.length; i++) { %>
  32. <div class="container">
  33. <label><%= posts[i].note %></label>
  34. <div class="container">
  35. <label><%= posts[i].date %></label>
  36. </div>
  37. </div>
  38. <% } %>
  39. </div>
Add Comment
Please, Sign In to add comment