Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. // Knappen
  3. var btn = document.getElementById("submitBtn");
  4. btn.addEventListener("click", updatePost, false);
  5.  
  6. function updatePost() {
  7.     fetch('http://localhost:4000/admin/edit', {
  8.         method: 'post',
  9.         title: document.getElementById('title').value,
  10.         content: document.getElementById('content').value,
  11.         id: document.getElementById('id').value
  12.     });
  13. }
  14.  
  15. // routen
  16.  
  17. var updatePost = function (req, res){
  18.     var title   = req.param('title'),
  19.         content   = req.param('content'),
  20.         id        = req.param('id');
  21.  
  22.     blogPost.update({
  23.         title:title,
  24.         content: content
  25.     },{
  26.         where: { id : id }
  27.     }).then(function() {
  28.         res.redirect('/admin');
  29.     });
  30. };
  31.  
  32. app.post('/edit', updatePost)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement