Skip to content

Commit 98a2fbd

Browse files
committed
extensions type 명시 제거 및 상수 export 추가
1 parent 22f5835 commit 98a2fbd

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

packages/fetcher/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export {
1111
handleGql401Error,
1212
NEED_REFRESH_IDENTIFIER,
1313
ACCESS_TOKEN_EXPIRED_EXCEPTION,
14+
UNAUTHORIZED_CODE,
1415
} from './response-handler'
1516
export {
1617
sessionRefresh,

packages/fetcher/src/response-handler.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,11 @@ export async function handle401Error<SuccessBody, FailureBody>(
5656
return NEED_LOGIN_IDENTIFIER
5757
}
5858

59-
const UNAUTHORIZED_CODE = 'UNAUTHORIZED'
60-
61-
interface ErrorResponse401 {
62-
status: number
63-
code: string
64-
sentryId: string
65-
}
59+
export const UNAUTHORIZED_CODE = 'UNAUTHORIZED'
6660

6761
export function handleGql401Error(error: GraphQLError) {
68-
if (error.extensions) {
69-
const extensions = error.extensions as unknown as ErrorResponse401
70-
if (extensions.code === UNAUTHORIZED_CODE) {
71-
return NEED_LOGIN_IDENTIFIER
72-
}
62+
const { extensions } = error
63+
if ('code' in extensions && extensions.code === UNAUTHORIZED_CODE) {
64+
return NEED_LOGIN_IDENTIFIER
7365
}
7466
}

0 commit comments

Comments
 (0)