-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
solution 4.9*: Pruebas de lista de blogs, paso 2
- Loading branch information
1 parent
f4361d4
commit 6b99032
Showing
4 changed files
with
40 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,15 @@ | ||
const blogsRouter = require('express').Router() | ||
const Blog = require('../models/blog') | ||
|
||
blogsRouter.get('/', (request, response) => { | ||
Blog.find({}).then((blogs) => { | ||
response.json(blogs) | ||
}) | ||
blogsRouter.get('/', async (request, response) => { | ||
const blogs = await Blog.find({}) | ||
response.json(blogs) | ||
}) | ||
|
||
blogsRouter.post('/', (request, response) => { | ||
blogsRouter.post('/', async (request, response) => { | ||
const blog = new Blog(request.body) | ||
|
||
blog.save().then((result) => { | ||
response.status(201).json(result) | ||
}) | ||
const result = blog.save() | ||
response.status(201).json(result) | ||
}) | ||
|
||
module.exports = blogsRouter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters