Skip to content

Commit

Permalink
fix/ unthorization 문제 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
sonagi98 committed Jul 24, 2023
1 parent f60d31b commit 81d237d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
10 changes: 9 additions & 1 deletion client/src/pages/MyPage/Bookmarks/MyBookmarks.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
import ShortMovieList from '../UI/ShortMovieList';
import { useEffect, useState } from 'react';
import axios from 'axios';
import { getCookie } from '../../../utils/cookie';

interface MyBookmarkProps {
id: number;
}

const MyBookmarks = ({ id }: MyBookmarkProps) => {
const token = getCookie('jwtToken');
const [bookmarks, setBookmark] = useState([]);
useEffect(() => {
const fetchBookmarks = async () => {
try {
const res = await axios.get(
`http://ec2-54-180-85-209.ap-northeast-2.compute.amazonaws.com:8080/members/${id}/bookmarks`
`http://ec2-54-180-85-209.ap-northeast-2.compute.amazonaws.com:8080/members/${id}/bookmarks`,
{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
},
}
);
if (res.status === 200) {
const data = res.data;
Expand Down
19 changes: 14 additions & 5 deletions client/src/pages/MyPage/MyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import MyReviews from './Reviews/MyReviews';
import UserInfo from './UserInfo/UserInfo';
import DeleteUserBtn from './UI/deleteUserBtn';
import { User } from './assets/types/User';
import { getCookie } from '../../utils/cookie';

const MyPage = () => {
//TODO: hook으로 분리
const [username, setName] = useState<string>('name');
const token = getCookie('jwtToken');
// const [username, setName] = useState<string>('name');
const [reviewCounter, setReviewCounter] = useState<number>(0);

const [user, setUser] = useState<User>({
username: username,
username: 'name',
reviews: reviewCounter,
memberId: 0,
});
Expand All @@ -21,14 +23,21 @@ const MyPage = () => {
const fetchInfo = async () => {
try {
const res = await axios.get(
'http://ec2-54-180-85-209.ap-northeast-2.compute.amazonaws.com:8080/members/mypage'
'http://ec2-54-180-85-209.ap-northeast-2.compute.amazonaws.com:8080/members/mypage',
{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
},
}
);

if (res.status === 200) {
const data = res.data;
setName(data.username);
// console.log(data);
// setName(data.username);
setUser({
username: username,
username: data.username,
reviews: 0,
memberId: data.memberId,
});
Expand Down
10 changes: 9 additions & 1 deletion client/src/pages/MyPage/Reviews/MyReviews.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react';
import ShortMovieList from '../UI/ShortMovieList';
import axios from 'axios';
import { getCookie } from '../../../utils/cookie';
// import { movies } from '../../UI/datalist';

interface MyReviewProps {
Expand All @@ -10,12 +11,19 @@ interface MyReviewProps {

const MyReviews = ({ reviewCounter, setReviewCount }: MyReviewProps) => {
// TODO: 페이지네이션 컴포넌트 만들고 페이지네이션으로 변경
const token = getCookie('jwtToken');
const [reviews, setReview] = useState([]);
useEffect(() => {
const fetchReviews = async () => {
try {
const res = await axios.get(
'http://ec2-54-180-85-209.ap-northeast-2.compute.amazonaws.com:8080/members/reviews?page=1'
'http://ec2-54-180-85-209.ap-northeast-2.compute.amazonaws.com:8080/members/reviews?page=1',
{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
},
}
);
if (res.status === 200) {
const data = res.data;
Expand Down

0 comments on commit 81d237d

Please sign in to comment.