We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d0e3f7a commit 262e7bcCopy full SHA for 262e7bc
1 file changed
packages/langbase/src/common/request.ts
@@ -65,6 +65,18 @@ export class Request {
65
// All endpoints should return headers if rawResponse is true
66
if (!isLllmGenerationEndpoint && options.body?.rawResponse) {
67
const responseData = await response.json();
68
+ // For array responses, attach rawResponse as a hidden property to preserve response type as array
69
+ // while still providing access to response headers when needed
70
+ if (Array.isArray(responseData)) {
71
+ Object.defineProperty(responseData, 'rawResponse', {
72
+ value: {
73
+ headers: Object.fromEntries(response.headers.entries()),
74
+ },
75
+ enumerable: false,
76
+ writable: true,
77
+ });
78
+ return responseData as T;
79
+ }
80
return {
81
...responseData,
82
rawResponse: {
0 commit comments