notices.js 492 Bytes
Newer Older
1
2
3
4
5
6
7
8
const express = require('express');
const Notice = require('../schemas/notice');

const router = express.Router();

router.get('/', function (req, res, next) {
    Notice.find({}).sort({ post_date: -1 })
        .then((notices) => {
Kim, Subin's avatar
Kim, Subin committed
9
            res.status(201).json(notices);
10
11
12
        })
        .catch((err) => {
            console.error(err);
Kim, Subin's avatar
Kim, Subin committed
13

14
15
            next(err);
        });
Kim, Subin's avatar
Kim, Subin committed
16
17
    // res.status(404).json({error:"없음."})
    res.status(201).json(notices);
18
19
20
});

module.exports = router;