node-superfetch
Advanced tools
Comparing version 0.0.2 to 0.0.3
20
index.js
@@ -36,13 +36,15 @@ const fetch = require('node-fetch'); | ||
return raw.toString(); | ||
}, | ||
get body() { | ||
if (/application\/json/gi.test(res.headers['content-type'])) { | ||
try { | ||
return JSON.parse(raw.toString()); | ||
} catch (err) { | ||
return raw.toString(); | ||
} | ||
} else { | ||
return raw; | ||
} | ||
} | ||
}; | ||
if (/application\/json/gi.test(res.headers['content-type'])) { | ||
try { | ||
res.body = JSON.parse(res.text); | ||
} catch (err) { | ||
res.body = res.text; | ||
} | ||
} else { | ||
res.body = raw; | ||
} | ||
if (!response.ok) { | ||
@@ -49,0 +51,0 @@ const err = new Error(`${res.status} ${res.statusText}`); |
{ | ||
"name": "node-superfetch", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"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
6909
101