-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
리스폰스 타입들이 잘못 작성되어서 수정하였습니다. 선언한 타입들을 재사용 가능하도록 export시켰습니다. module에서 같이 import 할 수 있습니다.
- Loading branch information
Showing
4 changed files
with
52 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,41 @@ | ||
import instance from '../axiosInstance'; | ||
import { handleResponse } from '../errorHandler'; | ||
|
||
interface LoginBody { | ||
export interface LoginBody { | ||
email: string; | ||
password: string; | ||
} | ||
|
||
interface ChangePasswordBody { | ||
export interface ChangePasswordBody { | ||
password: string; | ||
newPassword: string; | ||
} | ||
|
||
interface LoginResponse { | ||
status: number; | ||
message?: string; | ||
data: { | ||
user: { | ||
id: number; | ||
email: string; | ||
nickname: string; | ||
profileImageUrl?: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
accessToken: string; | ||
export interface LoginResponse { | ||
user: { | ||
id: number; | ||
email: string; | ||
nickname: string; | ||
profileImageUrl?: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
} | ||
|
||
interface ChangePasswordResponse { | ||
status: number; | ||
message?: string; | ||
accessToken: string; | ||
} | ||
|
||
// 로그인 요청 api | ||
export async function apiLoginRequest(body: LoginBody): Promise<LoginResponse> { | ||
const res = await instance.post<LoginResponse>('/auth/login', body); | ||
const responseData = await handleResponse(res); | ||
const token = responseData.data.accessToken; | ||
const token = responseData.accessToken; | ||
if (token) { | ||
localStorage.setItem('Token', token); | ||
} | ||
return responseData; | ||
} | ||
|
||
// 비밀번호 변경 요청 api | ||
export async function apiChangePassword( | ||
body: ChangePasswordBody, | ||
): Promise<string | ChangePasswordResponse> { | ||
const res = await instance.put<ChangePasswordResponse>( | ||
'/auth/password', | ||
body, | ||
); | ||
export async function apiChangePassword(body: ChangePasswordBody) { | ||
const res = await instance.put('/auth/password', body); | ||
return handleResponse(res); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters