Skip to content
Snippets Groups Projects
Commit b8b5afad authored by Chif Gergő's avatar Chif Gergő
Browse files

Now can add news

parent 25fee09c
Branches
No related tags found
2 merge requests!10Feature/12 dev auto deploy,!6Feature/news api
import { Request, Response, NextFunction } from 'express';
import News from '../../models/NewsSchema';
const addNews = () => {
return (req: Request, res: Response, next: NextFunction) => {
const news = new News();
news.title = req.body.title;
news.text = req.body.text;
news.publishedAt = new Date().toDateString()
news.save((err) => {
if(err){
} else {
res.status(201)
res.json(news)
};
});
};
};
export default addNews;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment