Skip to content

Commit de257f7

Browse files
committed
♻️ [refactor] : request body 추가 및 타입 선언
1 parent 6ccd304 commit de257f7

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

src/api/auth.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
11
import { axiosInstance } from '@/utils/axios'
22
import Cookies from 'js-cookie'
3+
import type { loginDataTypes } from '@/types/auth'
34

4-
export const postLogin = async (nickname: string, password: string) => {
5-
const body = {
6-
nickname: nickname,
7-
password: password
8-
}
9-
const sessionIdValue = '123'
10-
11-
const response = await axiosInstance.post('/api/auths/login', body, {
12-
headers: {
13-
sessionId: sessionIdValue
14-
}
5+
export const postLogin = async (loginData: loginDataTypes, sessionId: string) => {
6+
const response = await axiosInstance.post('/api/auths/login', loginData, {
7+
headers: { sessionId: sessionId }
158
})
16-
179
Cookies.set('accessToken', response.data.accessToken, {
1810
path: '/',
1911
sameSite: 'strict'
2012
})
21-
2213
return response.data
2314
}
2415

src/types/auth.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@ export interface User {
1212
memberRole: string
1313
memberStatus: string
1414
}
15+
16+
export interface loginDataTypes {
17+
nickname: string
18+
password: string
19+
}

src/views/LoginView.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@ const password = ref('')
5656
5757
const handleLogin = async () => {
5858
try {
59-
const res = await postLogin(nickname.value, password.value)
59+
const loginData = {
60+
nickname: nickname.value,
61+
password: password.value
62+
}
63+
const sessionId = '000'
64+
const res = await postLogin(loginData, sessionId)
6065
6166
if (res) {
6267
switch (res.memberInfo.memberRole) {

0 commit comments

Comments
 (0)