Skip to content

Commit 8a2dd06

Browse files
committed
fix: Response handler type
1 parent 45f9cac commit 8a2dd06

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/ResponseHandler.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type APIResponse<T> = {
1111
export async function handleAPIResponse<T>({
1212
response,
1313
options,
14-
}: APIResponseProps): Promise<Stream<T> | APIResponse<T>> {
14+
}: APIResponseProps): Promise<Stream<T> | Promise<APIResponse<T>>> {
1515
if (options.stream) {
1616
if (!response.body) {
1717
throw new AI21Error('Response body is null');
@@ -20,10 +20,5 @@ export async function handleAPIResponse<T>({
2020
}
2121

2222
const contentType = response.headers.get('content-type');
23-
const data = contentType?.includes('application/json') ? await response.json() : null;
24-
25-
return {
26-
data,
27-
response,
28-
};
23+
return contentType?.includes('application/json') ? await response.json() : null;
2924
}

0 commit comments

Comments
 (0)