NoticePage.js 975 Bytes
Newer Older
Ha YeaJin's avatar
pages    
Ha YeaJin committed
1
2
import React, { useState, useEffect } from 'react';
import Menu from '../Components/Menu';
3
import axios from 'axios';
Ha YeaJin's avatar
pages    
Ha YeaJin committed
4
5

function Notice() {
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    const [notices, setNotices] = useState([]);

    useEffect(() => {
        getNotice();
    }, []);

    function getNotice() {
        axios.get(`/notices`)
            .then(res => {
                if (res.status !== 201) {
                    alert(res.data.error);
                }
                console.log(res.data);
                setNotices(res.data);
            })
            .catch(err => {
                alert(err.error)
            });
    }
Ha YeaJin's avatar
pages    
Ha YeaJin committed
25
26
27
    return (
        <div>
            <Menu />
28
29
30
31
32
33
            <div className="container">
                <div className="row">
                    <div className="col-12">
                        {notices.map((notice) => <div>{notice.notice_title}</div>)}
                    </div>
                </div>
Ha YeaJin's avatar
pages    
Ha YeaJin committed
34
35
36
37
38
39
            </div>
        </div>
    )
}

export default Notice