import { Link } from "react-router-dom"; import { useState, useEffect } from "react"; import userApi from "../../apis/user.api"; const INIT_USER = { id: '', name: '', img: '', } const HomeProfile = () => { const [user, setUser] = useState(INIT_USER) const id = localStorage.getItem('user'); async function getUser(id) { try { // `/users/${userId}`랑 userId랑 같은지 확인 const User = await userApi.user(id) console.log(User) setUser(User.data) console.log(user) } catch (error) { // catchErrors(error, setError) } } useEffect(() => { getUser(id) }, [id]) return (
); }; export default HomeProfile;