minipass-fetch
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -13,3 +13,5 @@ 'use strict' | ||
convert = require('encoding').convert | ||
} catch (e) {} | ||
} catch (e) { | ||
// defer error until textConverted is called | ||
} | ||
@@ -73,12 +75,12 @@ const INTERNALS = Symbol('Body internals') | ||
json () { | ||
return this[CONSUME_BODY]().then(buf => { | ||
try { | ||
return JSON.parse(buf.toString()) | ||
} catch (er) { | ||
return Promise.reject(new FetchError( | ||
`invalid json response body at ${ | ||
this.url} reason: ${er.message}`, 'invalid-json')) | ||
} | ||
}) | ||
async json () { | ||
try { | ||
const buf = await this[CONSUME_BODY]() | ||
return JSON.parse(buf.toString()) | ||
} catch (er) { | ||
throw new FetchError( | ||
`invalid json response body at ${this.url} reason: ${er.message}`, | ||
'invalid-json' | ||
) | ||
} | ||
} | ||
@@ -85,0 +87,0 @@ |
{ | ||
"name": "minipass-fetch", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "An implementation of window.fetch in Node.js using Minipass streams", | ||
@@ -26,6 +26,7 @@ "license": "MIT", | ||
"@npmcli/eslint-config": "^3.0.1", | ||
"@npmcli/template-oss": "3.1.2", | ||
"@npmcli/template-oss": "3.5.0", | ||
"@ungap/url-search-params": "^0.2.2", | ||
"abort-controller": "^3.0.0", | ||
"abortcontroller-polyfill": "~1.7.3", | ||
"encoding": "^0.1.13", | ||
"form-data": "^4.0.0", | ||
@@ -65,4 +66,4 @@ "nock": "^13.2.4", | ||
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", | ||
"version": "3.1.2" | ||
"version": "3.5.0" | ||
} | ||
} |
46291
1291
11