Skip to content

Commit 0548dfc

Browse files
committed
refactor: 타입 맞춤
1 parent 2b21c75 commit 0548dfc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/apis/instance.request.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,16 @@ if (!BASE_URL) {
1313
throw new Error('BASE_URL이 ENV에서 설정되지 않았습니다.');
1414
}
1515

16-
type ErrorObject = Record<string, Error>;
16+
type ErrorType = {
17+
code: string;
18+
statusCode: number;
19+
};
1720

1821
type SuccessType<T> = {
1922
success: true;
2023
message: string;
2124
data: T;
22-
error: null;
25+
error: null | ErrorType;
2326
};
2427

2528
export type InitType<I> = Omit<NonNullable<FetchArgs[1]>, 'body'> & {
@@ -54,7 +57,7 @@ const fetch = returnFetch({
5457
export const instance = async <I, R>(
5558
input: URL | RequestInfo,
5659
init?: InitType<I>,
57-
error?: ErrorObject,
60+
error?: Record<string, Error>,
5861
): Promise<R> => {
5962
try {
6063
const data = await fetch('/api' + input, {

0 commit comments

Comments
 (0)