node-superfetch
Advanced tools
Comparing version 0.1.11 to 0.2.0
@@ -17,2 +17,3 @@ const fetch = require('node-fetch'); | ||
this.agent = options.agent || null; | ||
this.noResultData = options.noResultData || false; | ||
} | ||
@@ -28,3 +29,4 @@ | ||
}); | ||
const raw = await response.buffer(); | ||
let raw = null; | ||
if (!this.noResultData) raw = await response.buffer(); | ||
const headers = {}; | ||
@@ -40,5 +42,7 @@ for (const [header, value] of response.headers.entries()) headers[header] = value; | ||
get text() { | ||
if (this.noResultData) return null; | ||
return raw.toString(); | ||
}, | ||
get body() { | ||
if (this.noResultData) return null; | ||
if (/application\/json/gi.test(headers['content-type'])) { | ||
@@ -45,0 +49,0 @@ try { |
{ | ||
"name": "node-superfetch", | ||
"version": "0.1.11", | ||
"version": "0.2.0", | ||
"description": "A wrapper for node-fetch that makes it appear like superagent.", | ||
@@ -34,11 +34,11 @@ "main": "index.js", | ||
"dependencies": { | ||
"form-data": "^3.0.0", | ||
"node-fetch": "^2.6.0" | ||
"form-data": "^4.0.0", | ||
"node-fetch": "^2.6.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^14.14.22", | ||
"eslint": "^7.19.0", | ||
"eslint-config-amber": "^2.0.1", | ||
"eslint-plugin-json": "^2.0.1", | ||
"typescript": "^4.1.3" | ||
"@types/node": "^14.14.37", | ||
"eslint": "^7.23.0", | ||
"eslint-config-amber": "^2.0.4", | ||
"eslint-plugin-json": "^2.1.2", | ||
"typescript": "^4.2.3" | ||
}, | ||
@@ -45,0 +45,0 @@ "eslintConfig": { |
@@ -29,1 +29,10 @@ # node-superfetch | ||
`agent` (for setting the HTTP agent). `end` is also supported for callbacks. | ||
Additionally, you can also use the `noResultData` option to get everything | ||
except the actual result data of the request. This is essentially doing the | ||
request without calling any of `node-fetch`'s methods to parse the result data. | ||
```js | ||
const { headers, url } = await request.get('https://registry.npmjs.com/node-fetch', { noResultData: true }); | ||
console.log(url); // should log https://registry.npmjs.com/node-fetch | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10243
204
38
+ Addedform-data@4.0.1(transitive)
- Removedform-data@3.0.2(transitive)
Updatedform-data@^4.0.0
Updatednode-fetch@^2.6.1