-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInfoContent.js
54 lines (50 loc) · 1.58 KB
/
InfoContent.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import React from "react";
import axios from "axios";
import { useEffect, useState } from "react";
const InfoContent = () => {
const [userInfo, setUserInfo] = useState({
name: "",
email: "",
univ: "",
});
useEffect(() => {
axios.interceptors.request.use((config) => {
const userAccessToken = localStorage.getItem("accessToken");
if (userAccessToken) {
config.headers["X-ACCESS-TOKEN"] = `${userAccessToken}`;
}
return config;
});
axios
.get("https://www.wowmkt.kr/mypage/myinfo")
.then((res) => {
const data = res.data; // 예시: { name: "김와우", email: "wow1234@mail.com", univ: "와우대학교" }
setUserInfo(data); // 상태 업데이트
})
.catch((err) => {
alert("마이페이지 로딩 실패!");
});
}, []);
return (
<div className="MyInfo">
<div className="InfoContent">
<div className="MyInfoContent">
<div className="title">나의 정보</div>
<div className="info_space">
<div className="check_space">
<div className="name_subtitle">이름</div>
<div className="mail_subtitle">이메일</div>
<div className="univ_subtitle">소속학교</div>
</div>
<div className="info">
<div className="name">{userInfo.name}</div>
<div className="email">{userInfo.email}</div>
<div className="univ">{userInfo.univ}</div>
</div>
</div>
</div>
</div>
</div>
);
};
export default InfoContent;