Guest User

Untitled

a guest
Aug 16th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. /**
  2. * Add new note to Firebase
  3. * Real-Time Database
  4. */
  5. app.post('/addNote', (req, res)=> {
  6. var title = req.body.note.title;
  7. var body = req.body.note.body;
  8. var userId= req.body.note.uid;
  9.  
  10. db.notes.push({
  11. title: title,
  12. body: body,
  13. uid: userId
  14. })
  15. res.send("Success")
  16. })
  17.  
  18. app.get('/all', (req, res, next)=> {
  19. db.notes.on('value', snapshot => {
  20. return res.send(snapshot.val());
  21. })
  22. })
  23.  
  24. /**
  25. * Add new note to Firebase
  26. * Real-Time Database
  27. */
  28. app.post('/addNote', (req, res)=> {
  29. var title = req.body.note.title;
  30. var body = req.body.note.body;
  31. var userId= req.body.note.uid;
  32.  
  33. db.notes.push({
  34. title: title,
  35. body: body,
  36. uid: userId
  37. })
  38. res.send("Success")
  39. })
  40.  
  41. app.get('/all', (req, res, next)=> {
  42. db.notes.once('value', snapshot => {
  43. return res.send(snapshot.val());
  44. })
  45. })
Add Comment
Please, Sign In to add comment