notices.js 451 Bytes
Newer Older
Yoon, Daeki's avatar
Yoon, Daeki committed
1
2
3
4
5
6
const express = require('express');
const Notice = require('../models/notice');

const router = express.Router();

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

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

module.exports = router;