Skip to content

Instantly share code, notes, and snippets.

@barmgeat
Created October 31, 2019 06:51
Show Gist options
  • Save barmgeat/21db7232eeb8ff5c116b887cd3ab7b5c to your computer and use it in GitHub Desktop.
Save barmgeat/21db7232eeb8ff5c116b887cd3ab7b5c to your computer and use it in GitHub Desktop.
router.get('/addPost', async(req, res) =>{
try {
// add post:
const post = new Post({
title: 'Post 3 title',
des: 'Post 3 Description',
body: 'Post 3 Body',
tags: ['5dba7d7ae842b83c84344755', '5dba7eab7fb2bf4fe0d1122d', 'another tag id and so on']
});
post.save();
res.status(201).json(post);
} catch (error) {
res.status(400).json({error: error.message});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment