node-superfetch
Advanced tools
Comparing version 0.0.1 to 0.0.2
18
index.js
@@ -22,9 +22,12 @@ const fetch = require('node-fetch'); | ||
headers: this.headers, | ||
follow: this.redirect | ||
follow: this.redirect, | ||
body: this.body | ||
}); | ||
const raw = await response.buffer(); | ||
const headers = {}; | ||
for (const [header, value] of Object.entries(response.headers.raw())) headers[header] = value.join(''); | ||
const res = { | ||
status: response.status, | ||
statusText: response.statusText, | ||
headers: response.headers.raw(), | ||
headers, | ||
ok: response.ok, | ||
@@ -82,3 +85,12 @@ raw, | ||
send(body) { | ||
send(body, raw = false) { | ||
if (!raw && body !== null && typeof body === 'object') { | ||
const header = this.headers['content-type']; | ||
if (header) { | ||
if (/application\/json/gi.test(header)) body = JSON.stringify(body); | ||
} else { | ||
this.set({ 'Content-Type': 'application/json' }); | ||
body = JSON.stringify(body); | ||
} | ||
} | ||
this.body = body; | ||
@@ -85,0 +97,0 @@ return this; |
{ | ||
"name": "node-superfetch", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A wrapper for node-fetch that makes it appear like superagent.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
6869
99