Skip to content

Commit

Permalink
getting all posts
Browse files Browse the repository at this point in the history
  • Loading branch information
JaberHPranto committed Sep 15, 2021
1 parent 6c75a83 commit dbbee51
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions server/controller/blogController.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import BlogPost from '../models/blogModel.js';
// Get all blog posts
export const getBlogs = (req, res) => {
res.send("Everything works !!!")
export const getBlogs = async (req, res) => {
try {
const blogs = await BlogPost.find()
res.status(200).json(blogs)
} catch (err) {
res.status(401).json({
error: err.message
})
}
}

// Create a blog
Expand Down

0 comments on commit dbbee51

Please sign in to comment.