File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -38,9 +38,26 @@ const Profile = ({ userInfo }) => {
3838 const navigate = useNavigate ( ) ; // 페이지 이동 함수
3939
4040 // 새 펫 받기 버튼 클릭 핸들러
41- const handleGetNewPet = ( ) => {
42- alert ( "새 펫을 받는 기능은 아직 구현되지 않았습니다! 🐣" ) ;
43- } ;
41+ const handleGetNewPet = async ( ) => {
42+ try {
43+ const response = await fetch ( "/api/pet/new" , {
44+ method : "POST" ,
45+ headers : {
46+ "Content-Type" : "application/json" ,
47+ } ,
48+ } ) ;
49+
50+ if ( ! response . ok ) {
51+ throw new Error ( "새 펫을 받을 수 없습니다." ) ;
52+ }
53+
54+ alert ( "새 펫을 성공적으로 받았습니다! 🎉" ) ;
55+ window . location . reload ( ) ; // 페이지 새로고침
56+ } catch ( error ) {
57+ console . error ( "에러 발생:" , error ) ;
58+ alert ( "펫을 받는 데 실패했습니다. 다시 시도해주세요." ) ;
59+ }
60+ } ;
4461
4562 // 프로필 정보 자동 새로고침 함수
4663 const refreshProfileData = async ( ) => {
You can’t perform that action at this time.
0 commit comments