From dbfd910e4474b220bf24ad29876918994dfb3cfa Mon Sep 17 00:00:00 2001 From: ksbin1025 Date: Fri, 5 Nov 2021 19:34:15 +0900 Subject: [PATCH] =?UTF-8?q?TodoList=20=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/Menu/Menu.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/client/src/components/Menu/Menu.js b/client/src/components/Menu/Menu.js index 4d1f5de..a1cdef5 100644 --- a/client/src/components/Menu/Menu.js +++ b/client/src/components/Menu/Menu.js @@ -1,10 +1,30 @@ +import { useState, useEffect } from "react"; import { Link } from "react-router-dom"; +import todoApi from "../../apis/todo.api"; import { useAuth } from "../../utils/context.js"; +import catchErrors from "../../utils/catchErrors"; import moment from "moment"; import styles from "./menu.module.scss"; const Menu = () => { const { user, logout } = useAuth(); + const [todoList, setTodoList] = useState([]) + const [error, setError] = useState(""); + + useEffect(() => { + todayTodo() + }, []) + + async function todayTodo() { + try { + setError("") + const result = await todoApi.getTodo(user.id, moment().format("YYYY-MM-DD")) + console.log("client resList",result) + setTodoList(result) + } catch (error) { + catchErrors(error, setError) + } + } return ( <> -- GitLab