var express = require('express'); let res = require('express/lib/response'); var router = express.Router(); let blog = []; /* GET home page. */ router.route('/') .get((req, res, next) => { // => Pfeilfunktion: ersetzt function() res.send({ blog }); }) .post((req, res, next) => { let blogeintrag = []; let title = req.body.title; let username = req.body.username; let date = req.body.date; let text = req.body.text; console.log(title); blogeintrag.push(title, username, date, text); blog.push(blogeintrag); res.render('blogPost', { title: 'Nächster Post' }) }); router.get('/newPost', function (req, res, next) { res.render('blogPost', { title: 'BlogEintrag' }); }); router.get('/:id', function (req, res, next) { let blogID = req.params.id; console.log(blogID); res.send(blog[blogID]); }); module.exports = router;