blob: 78540c8e7c3dd0bccc9eb02bad78c47a993e8337 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
const blogsRouter = require('express').Router()
const Blog = require('../models/blog')
blogsRouter.get('/', (request, response) => {
Blog
.find({})
.then(blogs => {
response.json(blogs)
})
.catch((error) => {
console.log(error.message)
})
})
blogsRouter.post('/', (request, response) => {
const blog = new Blog(request.body)
blog
.save()
.then(result => {
response.status(201).json(result)
})
})
module.exports = blogsRouter
|