File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
packages/superagent-wrapper/src Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ type SuperagentLike<Req> = {
5353
5454export type Response = {
5555 body : unknown ;
56+ text : unknown ;
5657 status : number ;
5758} ;
5859
@@ -126,19 +127,20 @@ const patchRequest = <
126127
127128 patchedReq . decode = ( ) =>
128129 req . then ( ( res ) => {
129- const { body, status } = res ;
130+ const { body, text, status } = res ;
131+ const bodyOrText = body || text ;
130132
131133 if ( ! hasCodecForStatus ( route . response , status ) ) {
132134 return decodedResponse ( {
133135 // DISCUSS: what's this non-standard HTTP status code?
134136 status : 'decodeError' ,
135137 error : `No codec for status ${ status } ` ,
136- body,
138+ body : bodyOrText ,
137139 original : res ,
138140 } ) ;
139141 }
140142 return pipe (
141- route . response [ status ] . decode ( res . body ) ,
143+ route . response [ status ] . decode ( bodyOrText ) ,
142144 E . map ( ( body ) =>
143145 decodedResponse < Route > ( {
144146 status,
@@ -151,7 +153,7 @@ const patchRequest = <
151153 decodedResponse < Route > ( {
152154 status : 'decodeError' ,
153155 error : PathReporter . failure ( error ) . join ( '\n' ) ,
154- body : res . body ,
156+ body : bodyOrText ,
155157 original : res ,
156158 } ) ,
157159 ) ,
You can’t perform that action at this time.
0 commit comments