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

Now can add news

parent 25fee09c
No related branches found
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.
Finish editing this message first!
Please register or to comment