import React, { useState, useEffect, useRef } from 'react'; import Menu from '../Components/Menu'; import axios from 'axios'; import { Link } from 'react-router-dom'; import { Container, Row, Col, Card, Accordion, Button } from 'react-bootstrap'; function Notice() { const [notices, setNotices] = useState([]); useEffect(() => { getNotice(); }, []); function dateForm(day) { const post_day = new Date(day); let year = post_day.getFullYear(); let month = post_day.getMonth() + 1; let date = post_day.getDate(); month = month < 10 ? '0' + month : month; date = date < 10 ? '0' + date : date; const new_date = year + "-" + month + "-" + date; return new_date } function getNotice() { axios.get(`/notices`) .then(res => { if (res.status !== 201) { alert(res.data.error); } setNotices(res.data); }) .catch(err => { alert(err.error) }); } return (

공지사항 글 작성

{notices.map((notice, index) => {notice.notice_title} {dateForm(notice.post_date)} {notice.notice_content} )}
) } export default Notice;