@nxtedition/nxt-undici 2.0.5 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +5 -5
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -225,7 +225,6 @@ export async function request(url, opts) {
|
|
|
225
225
|
dispatch = (opts, handler) => dispatcher.dispatch(opts, handler)
|
|
226
226
|
dispatch = dispatchers.catch(dispatch)
|
|
227
227
|
dispatch = dispatchers.requestBodyFactory(dispatch)
|
|
228
|
-
dispatch = dispatchers.abort(dispatch)
|
|
229
228
|
dispatch = dispatchers.log(dispatch)
|
|
230
229
|
dispatch = dispatchers.requestId(dispatch)
|
|
231
230
|
dispatch = dispatchers.responseRetry(dispatch)
|
|
@@ -332,10 +331,11 @@ export async function request(url, opts) {
|
|
|
332
331
|
await res.dump()
|
|
333
332
|
} else if (res.statusCode >= 400) {
|
|
334
333
|
// TODO (fix): Limit the size of the body?
|
|
335
|
-
const data =
|
|
336
|
-
res.
|
|
337
|
-
|
|
338
|
-
|
|
334
|
+
const data = /^application\/json$/i.test(res.headers['content-type'])
|
|
335
|
+
? await res.json()
|
|
336
|
+
: /^text-.+/i.test(res.headers['content-type'])
|
|
337
|
+
? await res.text()
|
|
338
|
+
: await res.dump()
|
|
339
339
|
throw createError(res.statusCode, { headers, data })
|
|
340
340
|
}
|
|
341
341
|
|