Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FE-69 ♻️ mutation hook 에러처리 변경 #69

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/hooks/useRegisterMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import postSignup from '@/apis/auth';
import { toast } from '@/components/ui/use-toast';
import { useMutation } from '@tanstack/react-query';
import { useRouter } from 'next/router';
import { AxiosError } from 'axios';
import { isAxiosError } from 'axios';

const useRegisterMutation = () => {
const router = useRouter();
Expand All @@ -14,16 +14,16 @@ const useRegisterMutation = () => {
localStorage.setItem('refreshToken', data.refreshToken);
router.push('/');
},
onError: (error: AxiosError) => {
if (!error.response) {
onError: (error) => {
if (!isAxiosError(error)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍

toast({
description: '네트워크 오류가 발생했습니다. 인터넷 연결을 확인해주세요.',
className: 'border-state-error text-state-error font-semibold',
});
return;
}

const { status } = error.response;
const { status } = error.response || {};

if (status === 400) {
toast({
Expand Down
Loading