import React, { useState, useEffect } from 'react'; import Menu from '../Components/Menu'; import axios from 'axios'; import 'bootstrap/dist/css/bootstrap.css'; function Check(props) { function getReserve() { axios.get(`/reserves/${props.match.params.id}`, { headers: { authorization: localStorage.getItem('token') }, }) .then(res => { if (res.status !== 201) { alert(res.data.error); } console.log(res.data); setReserve(res.data); }) .catch(err => { alert(err.error) }); } function remove(index) { axios.delete(`/reserves/${reserve[index]._id}`) .then(res => { if (res.status === 404) return alert(res.data.error) alert("삭제되었습니다!") getReserve(); }) .catch(err => { alert(err.error) }); }; const [reserve, setReserve] = useState([]); useEffect(() => { getReserve(); }, []) return (
check {reserve.map((reserve, index) => { return ( ) })}
아이디 이름 날짜 강의실 예약취소
{props.match.params.id} {reserve.name} {reserve.date} {reserve.room}
) } export default Check