We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 45f9cac commit 8a2dd06Copy full SHA for 8a2dd06
src/ResponseHandler.ts
@@ -11,7 +11,7 @@ type APIResponse<T> = {
11
export async function handleAPIResponse<T>({
12
response,
13
options,
14
-}: APIResponseProps): Promise<Stream<T> | APIResponse<T>> {
+}: APIResponseProps): Promise<Stream<T> | Promise<APIResponse<T>>> {
15
if (options.stream) {
16
if (!response.body) {
17
throw new AI21Error('Response body is null');
@@ -20,10 +20,5 @@ export async function handleAPIResponse<T>({
20
}
21
22
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
- };
+ return contentType?.includes('application/json') ? await response.json() : null;
29
0 commit comments