From 538f28f11c4e10279e38fce92b2e81fd0336345c Mon Sep 17 00:00:00 2001 From: nijuy Date: Sat, 12 Aug 2023 21:51:50 +0900 Subject: [PATCH] =?UTF-8?q?fix(Notification):=20api=20url=20=EC=88=98?= =?UTF-8?q?=EC=A0=95,=20=EC=9A=94=EC=B2=AD=20=ED=97=A4=EB=8D=94=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Notification.jsx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/pages/Notification.jsx b/src/pages/Notification.jsx index 53c1989..38d51fc 100644 --- a/src/pages/Notification.jsx +++ b/src/pages/Notification.jsx @@ -7,7 +7,7 @@ import { getMessaging, getToken } from 'firebase/messaging'; import notification from '../assets/notification.svg'; import ToggleButton from '../components/ToggleButton'; import { firebaseVapidKey } from '../data/firebaseConfig'; - +import { getToken as getAccessToken } from '../utils/tokenUtil'; import '../css/Notification.css'; const Notification = () => { @@ -17,6 +17,8 @@ const Notification = () => { const [toggleStatus, setToggleStatus] = useState([]); const [notifyOn, setNotifyOn] = useState(false); + const accessToken = getAccessToken(); + const navigate = useNavigate(); const handleAllToggleStatus = (checked) => { @@ -41,7 +43,6 @@ const Notification = () => { const onClickSave = () => { const requestData = { - memberId: 0, notifyOn, notificationList: [...notificationStatus].reduce((object, [key, value]) => { object[key] = value; @@ -50,7 +51,11 @@ const Notification = () => { }; try { - axios.post('https://api.bbiyong-bbiyong.seoul.kr/notification/save/topic', requestData); + axios.post('https://api.bbiyong-bbiyong.seoul.kr/topic', requestData, { + headers: { + Authorization: `Bearer ${accessToken}`, + }, + }); navigate('/'); } catch (e) { alert('설정 저장 중 에러가 발생했습니다! 잠시 후 다시 시도해주세요'); @@ -80,10 +85,13 @@ const Notification = () => { .catch((error) => { console.log('FCM 토큰 가져오기 오류 : ', error); }); + const getNotificationList = async () => { - const response = await axios.get( - 'https://api.bbiyong-bbiyong.seoul.kr/notification/0/get/topic', - ); + const response = await axios.get('https://api.bbiyong-bbiyong.seoul.kr/topic', { + headers: { + Authorization: `Bearer ${accessToken}`, + }, + }); setNotificationStatus( Object.keys(response.data.data.notificationList).reduce((map, key) => {