Skip to content

Commit

Permalink
feat: Add v2 support for response headers. (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrderyk authored Jul 11, 2024
1 parent 5c65173 commit d4c1e85
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions src/apiV2/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,8 @@ export const streamQueryV2 = async ({
};

try {
const { cancelStream, stream, status } = await generateStream(
headers,
JSON.stringify(body),
url
);
const { cancelStream, stream, status, responseHeaders } =
await generateStream(headers, JSON.stringify(body), url);

const consumeStream = async () => {
try {
Expand Down Expand Up @@ -211,7 +208,7 @@ export const streamQueryV2 = async ({

consumeStream();

return { cancelStream, request, status };
return { cancelStream, request, status, responseHeaders };
} catch (error) {
if (error instanceof Error) {
onStreamEvent({
Expand Down
1 change: 1 addition & 0 deletions src/common/generateStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const generateStream = async (
stream: getIterableStream(response.body),
cancelStream: () => controller.abort(),
status: response.status,
responseHeaders: response.headers,
};
};

Expand Down

0 comments on commit d4c1e85

Please sign in to comment.