File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
packages/langbase/src/common Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,18 @@ export class Request {
6565 // All endpoints should return headers if rawResponse is true
6666 if ( ! isLllmGenerationEndpoint && options . body ?. rawResponse ) {
6767 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+ }
6880 return {
6981 ...responseData ,
7082 rawResponse : {
You can’t perform that action at this time.
0 commit comments