Skip to content

Commit 1bfaaab

Browse files
장아영장아영
authored andcommitted
[#128] 🐛 fix ky error
1 parent 5d29078 commit 1bfaaab

File tree

6 files changed

+9
-31
lines changed

6 files changed

+9
-31
lines changed

queries/useSignIn.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@ export const useSignInMutation = () => {
1111

1212
return useMutation({
1313
mutationFn: SignIn,
14-
onSuccess: (response: Response) => {
15-
if (!response.ok) {
16-
console.error('Login Failed')
17-
alert('로그인 실패: 서버 실패 응답')
18-
return
19-
}
20-
21-
const result = response.json()
14+
onSuccess: (result) => {
2215
console.log('Login successful', result)
2316

2417
alert('로그인 성공')

queries/useSignOut.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@ export const useSignOutMutation = () => {
1111

1212
return useMutation({
1313
mutationFn: SignOut,
14-
onSuccess: (response: Response) => {
15-
if (!response.ok) {
16-
console.error('Logout Failed')
17-
alert('로그아웃 실패')
18-
return
19-
}
20-
21-
const result = response.json()
14+
onSuccess: result => {
2215
console.log('로그아웃 성공', result)
2316

2417
alert('로그아웃 성공')

queries/useSignUp.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,8 @@ export const useSignUpMutation = () => {
1111

1212
return useMutation({
1313
mutationFn: SignUp,
14-
onSuccess: (response: Response) => {
15-
if (!response.ok) {
16-
console.error('Login Failed')
17-
alert('회원가입 실패')
18-
return
19-
}
20-
21-
const result = response.json()
14+
onSuccess: (result) => {
2215
console.log('회원가입 성공', result)
23-
2416
alert('회원가입 성공')
2517
router.push(`/sign-in`)
2618
},

src/app/api/auth/refresh/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const POST = async (req: Request): Promise<NextResponse> => {
99

1010
try {
1111
const { accessToken } = await backendApi
12-
.post('/refresh', { json: { refreshToken } })
12+
.post('refresh', { json: { refreshToken } })
1313
.json<{ accessToken: string }>()
1414
return NextResponse.json({ success: true, accessToken })
1515
} catch (error: any) {

src/middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export async function middleware(req: NextRequest) {
2626
try {
2727
type RefreshToken = { accessToken: string }
2828
const { accessToken: newAccessToken } = await proxyApi
29-
.post(`/api/auth/refresh`, {
29+
.post(`api/auth/refresh`, {
3030
json: { refreshToken },
3131
})
3232
.json<RefreshToken>()

src/services/auth/auth.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { SignInRequest, SignUpRequest } from '@/types/auth.types'
33
import { backendApi, proxyApi } from '@/services/api'
44

55
export const SignUp = async (data: SignUpRequest): Promise<Response> => {
6-
return await backendApi.post(`/v1/auth/sign-up`, { json: data }).json()
6+
return await backendApi.post(`v1/auth/sign-up`, { json: data }).json()
77
}
88

99
export const SignIn = async (data: SignInRequest): Promise<Response> => {
10-
return await proxyApi.post(`/api/auth/sign-in`, { json: data }).json()
10+
return await proxyApi.post(`api/auth/sign-in`, { json: data }).json()
1111
}
1212

13-
export const SignOut = async () => {
14-
return await proxyApi.post(`/api/auth/sign-out`).json()
13+
export const SignOut = async (): Promise<Response> => {
14+
return await proxyApi.post(`api/auth/sign-out`)
1515
}

0 commit comments

Comments
 (0)