Skip to content

Commit 62acfb7

Browse files
perf: Adapting the unified response model
1 parent f2315cf commit 62acfb7

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

frontend/src/api/login.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ export const AuthApi = {
66
}>('/login/access-token', credentials, {
77
headers: {
88
'Content-Type': 'application/x-www-form-urlencoded'
9-
},
10-
requestOptions: {
11-
rawResponse: true,
129
}
1310
}),
1411
logout: () => request.post('/auth/logout')

frontend/src/stores/user.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export const useUserStore = defineStore('user', () => {
99

1010
const login = async (formData: { username: string; password: string }) => {
1111
username.value = formData.username
12-
const res = await AuthApi.login(formData)
13-
token.value = res.data.access_token
12+
const res: any = await AuthApi.login(formData)
13+
token.value = res.access_token
1414
wsCache.set('user.token', token.value)
1515
username.value = formData.username
1616
}

frontend/src/utils/request.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ class HttpService {
9494
/* if (response.data?.success !== true) {
9595
return Promise.reject(response.data)
9696
} */
97+
if (response.data?.code === 0) {
98+
return response.data.data
99+
} else if (response.data?.code) {
100+
return Promise.reject(response.data)
101+
}
97102
return response.data
98103
},
99104
async (error: AxiosError) => {

0 commit comments

Comments
 (0)