Skip to content

Commit e2d8513

Browse files
committed
Merge branch 'dev' of https://github.com/boostcampwm-2022/web27-Wabinar into feat/#37-K
2 parents 6079953 + 17bf19d commit e2d8513

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

client/src/apis/auth.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1+
import { http } from './http';
12
import { OK, CREATED } from './http-status';
2-
import { baseRequest } from './util';
33

44
export const getAuth = async () => {
5-
const res = await baseRequest.get(`/auth`);
5+
const res = await http.get(`/auth`);
66

77
if (res.status !== OK) throw new Error();
88

99
return res.data;
1010
};
1111

1212
export const postAuthLogin = async (code: string) => {
13-
const res = await baseRequest.post(`/auth/login`, { code });
13+
const res = await http.post(`/auth/login`, { code });
1414

1515
if (res.status !== CREATED) throw new Error();
1616

1717
return res.data;
1818
};
1919

2020
export const deleteAuthlogout = async () => {
21-
const res = await baseRequest.delete(`/auth/logout`);
21+
const res = await http.delete(`/auth/logout`);
2222

2323
if (res.status !== OK) throw new Error();
2424

client/src/apis/util.ts renamed to client/src/apis/http.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import env from 'config';
33

44
const SERVER_PATH = env.SERVER_PATH;
55

6-
export const baseRequest = axios.create({
6+
export const http = axios.create({
77
baseURL: SERVER_PATH,
8-
withCredentials: true,
98
});

client/src/apis/user.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { baseRequest } from './util';
1+
import { http } from './http';
2+
import { OK } from './http-status';
23

34
export const getWorkspaces = async (userId: number) => {
4-
try {
5-
const { data } = await baseRequest.get(`/user/${userId}/workspace`);
5+
const res = await http.get(`/user/${userId}/workspace`);
66

7-
return data;
8-
} catch (e) {
9-
console.log(e);
10-
}
7+
if (res.status !== OK) throw new Error();
8+
9+
return res.data;
1110
};

0 commit comments

Comments
 (0)