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> = {
53
53
54
54
export type Response = {
55
55
body : unknown ;
56
+ text : unknown ;
56
57
status : number ;
57
58
} ;
58
59
@@ -126,19 +127,20 @@ const patchRequest = <
126
127
127
128
patchedReq . decode = ( ) =>
128
129
req . then ( ( res ) => {
129
- const { body, status } = res ;
130
+ const { body, text, status } = res ;
131
+ const bodyOrText = body || text ;
130
132
131
133
if ( ! hasCodecForStatus ( route . response , status ) ) {
132
134
return decodedResponse ( {
133
135
// DISCUSS: what's this non-standard HTTP status code?
134
136
status : 'decodeError' ,
135
137
error : `No codec for status ${ status } ` ,
136
- body,
138
+ body : bodyOrText ,
137
139
original : res ,
138
140
} ) ;
139
141
}
140
142
return pipe (
141
- route . response [ status ] . decode ( res . body ) ,
143
+ route . response [ status ] . decode ( bodyOrText ) ,
142
144
E . map ( ( body ) =>
143
145
decodedResponse < Route > ( {
144
146
status,
@@ -151,7 +153,7 @@ const patchRequest = <
151
153
decodedResponse < Route > ( {
152
154
status : 'decodeError' ,
153
155
error : PathReporter . failure ( error ) . join ( '\n' ) ,
154
- body : res . body ,
156
+ body : bodyOrText ,
155
157
original : res ,
156
158
} ) ,
157
159
) ,
You can’t perform that action at this time.
0 commit comments