Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Knappen
- var btn = document.getElementById("submitBtn");
- btn.addEventListener("click", updatePost, false);
- function updatePost() {
- fetch('http://localhost:4000/admin/edit', {
- method: 'post',
- title: document.getElementById('title').value,
- content: document.getElementById('content').value,
- id: document.getElementById('id').value
- });
- }
- // routen
- var updatePost = function (req, res){
- var title = req.param('title'),
- content = req.param('content'),
- id = req.param('id');
- blogPost.update({
- title:title,
- content: content
- },{
- where: { id : id }
- }).then(function() {
- res.redirect('/admin');
- });
- };
- app.post('/edit', updatePost)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement