Guest User

Untitled

a guest
Dec 17th, 2017
660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. // 'async' function mock
  2. const getUsersJSON = function getUsersJSON() {
  3. return new Promise((resolve) => {
  4. const users = [
  5. {
  6. id: 1,
  7. firstName: 'Bob',
  8. lastName: 'Smith',
  9. email: 'bob@gmail.com',
  10. },
  11. {
  12. id: 2,
  13. firstName: 'Tammy',
  14. lastName: 'Norton',
  15. email: 'tnorton@yahoo.com',
  16. },
  17. {
  18. id: 3,
  19. firstName: 'Tina',
  20. lastName: 'Lee',
  21. email: 'lee.tina@hotmail.com, ',
  22. },
  23. ];
  24. resolve(users);
  25. });
  26. };
  27.  
  28. /*
  29. * GET /users route to retrieve all the users.
  30. * EXAMPLE
  31. */
  32. app.get('/users', async (req, res) => {
  33. const users = await getUsersJSON();
  34. res.json(users);
  35. });
Add Comment
Please, Sign In to add comment