File tree Expand file tree Collapse file tree 3 files changed +11
-13
lines changed Expand file tree Collapse file tree 3 files changed +11
-13
lines changed Original file line number Diff line number Diff line change 1+ import { http } from './http' ;
12import { OK , CREATED } from './http-status' ;
2- import { baseRequest } from './util' ;
33
44export 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
1212export 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
2020export 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
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import env from 'config';
33
44const 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} ) ;
Original file line number Diff line number Diff line change 1- import { baseRequest } from './util' ;
1+ import { http } from './http' ;
2+ import { OK } from './http-status' ;
23
34export 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} ;
You can’t perform that action at this time.
0 commit comments