File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -18,17 +18,21 @@ export interface Config {
1818export class DuffelError extends Error {
1919 public meta : ApiResponseMeta
2020 public errors : ApiResponseError [ ]
21+ public headers : Record < string , string >
2122
2223 constructor ( {
2324 meta,
2425 errors,
26+ headers,
2527 } : {
2628 meta : ApiResponseMeta
2729 errors : ApiResponseError [ ]
30+ headers : Record < string , string >
2831 } ) {
2932 super ( )
3033 this . meta = meta
3134 this . errors = errors
35+ this . headers = headers
3236 }
3337}
3438
@@ -129,10 +133,10 @@ export class Client {
129133 }
130134
131135 if ( ! response . ok || ( 'errors' in responseBody && responseBody . errors ) ) {
132- throw new DuffelError ( responseBody )
136+ throw new DuffelError ( { ... responseBody , headers : response . headers } )
133137 }
134138
135- return responseBody
139+ return { ... responseBody , headers : response . headers }
136140 }
137141
138142 async * paginatedRequest < T_Data = any > ( {
Original file line number Diff line number Diff line change @@ -73,6 +73,11 @@ export interface DuffelResponse<T_Data> {
7373 * Optional metadata for the request
7474 */
7575 meta ?: PaginationMeta
76+
77+ /**
78+ * The headers from the http response
79+ */
80+ headers ?: Record < string , string >
7681}
7782
7883export interface SDKOptions {
You can’t perform that action at this time.
0 commit comments