File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,13 +5,15 @@ export type ApiResponse<T> =
55 | {
66 type : 'success' ;
77 response : T ;
8+ originalResponse : Response ;
89 errors ?: never ;
910 status : number ;
1011 }
1112 | {
1213 type : 'error' ;
1314 source : ErrorSource ;
1415 response ?: never ;
16+ originalResponse : Response ;
1517 errors : Errors ;
1618 status : number ;
1719 } ;
@@ -27,13 +29,15 @@ export const handleFetchResponse = <ResponseType>(handleResponse: HandleResponse
2729 type : 'success' ,
2830 status : response . status ,
2931 response : handledResponse ,
32+ originalResponse : response ,
3033 } ) ,
3134 )
3235 : getJsonResponse ( response ) . then (
3336 ( jsonResponse ) : ApiResponse < ResponseType > => ( {
3437 type : 'error' ,
3538 status : response . status ,
3639 ...getErrorForBadStatusCode ( jsonResponse ) ,
40+ originalResponse : response ,
3741 } ) ,
3842 )
3943 ) . catch ( error => {
@@ -51,6 +55,7 @@ export const handleFetchResponse = <ResponseType>(handleResponse: HandleResponse
5155 type : 'error' ,
5256 source : 'decoding' ,
5357 status : response . status ,
58+ originalResponse : response ,
5459 errors : [ error . message ] ,
5560 } ;
5661 } else {
Original file line number Diff line number Diff line change @@ -193,3 +193,10 @@ describe('requestParams', () => {
193193 } ) ;
194194 } ) ;
195195} ) ;
196+
197+ describe ( 'ApiResponse' , ( ) => {
198+ const api = createApi ( { accessKey : 'MY_ACCESS_KEY' } ) ;
199+ api . topics . get ( { topicIdOrSlug : 'foo' } ) . then ( apiResponse => {
200+ apiResponse . originalResponse . headers . get ( 'content-type' ) ;
201+ } ) ;
202+ } ) ;
You can’t perform that action at this time.
0 commit comments