-
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.
- Loading branch information
Showing
93 changed files
with
3,236 additions
and
708 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +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; | ||
user?: { | ||
export interface LoginResponse { | ||
user: { | ||
id: number; | ||
email: string; | ||
nickname: string; | ||
profileImageUrl?: string; | ||
createdAt: string; | ||
updatedAt: string; | ||
}; | ||
accessToken?: 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); | ||
localStorage.setItem('Token', responseData.accessToken); | ||
return handleResponse(res); | ||
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); | ||
} |
Oops, something went wrong.