You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
880 B
35 lines
880 B
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;
|