Comparing version 1.0.6 to 1.0.7
@@ -10,3 +10,2 @@ "use strict"; | ||
if (typeof(opts) !== "string" && !opts.hasOwnProperty("url")) throw "Missing url option from options for request method."; | ||
if (!cb) throw "Missing callback for request method."; | ||
@@ -47,3 +46,3 @@ var addr; | ||
res.on("end", () => { | ||
cb(null, resBody, res); | ||
if (cb) cb(null, resBody, res); | ||
}); | ||
@@ -60,3 +59,3 @@ }; | ||
default: | ||
cb("Invalid / unknown address protocol. (Expected HTTP or HTTPS.)", null, null); | ||
if (cb) cb("Invalid / unknown address protocol. (Expected HTTP or HTTPS.)", null, null); | ||
return; | ||
@@ -66,3 +65,3 @@ } | ||
req.on("error", (err) => { | ||
cb(err, null, null); | ||
if (cb) cb(err, null, null); | ||
}); | ||
@@ -69,0 +68,0 @@ |
{ | ||
"name": "phin", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Ultra-simple, lightweight, dependency-free Node.JS HTTP request client", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,3 +17,3 @@ # phin | ||
p("https://www.ony.io", function(err, body, response) { | ||
p("https://www.ony.io", (err, body, response) => { | ||
if (!err) console.log(body); | ||
@@ -41,3 +41,3 @@ }); | ||
} | ||
}) | ||
}); | ||
``` | ||
@@ -55,3 +55,3 @@ | ||
}) | ||
}, function(err, body, response) { | ||
}, (err, body, response) => { | ||
if (!err) console.log("Sent data!"); | ||
@@ -67,3 +67,3 @@ }); | ||
"auth": "ethan:letmein" | ||
}, function(err, body, response) { | ||
}, (err, body, response) => { | ||
if (!err) console.log(body); | ||
@@ -78,3 +78,3 @@ }); | ||
"url": "https://ethan:letmein@ony.io:8080" | ||
}, function(err, body, response) { | ||
}, (err, body, response) => { | ||
if (!err) console.log(body); | ||
@@ -91,3 +91,3 @@ }); | ||
* `options` **required** - {} - object containing request options OR string URL to send GET request to | ||
* `options` **required** - __Object or String__ - object containing request options OR string URL to send GET request to | ||
* `url` **required** - _String_ - URL to request (Can include port, auth. These will be used if their respective options are not present.) | ||
@@ -99,3 +99,3 @@ * `method` - _String_ - Default: `'GET'` - Request method. Ex. `'GET'` | ||
* `auth` - _String_ - Authorization in `'user:pass'` format | ||
* `callback` **required** - function(err, body, response) {} - callback method | ||
* `callback` - (err, body, response) {} - callback method | ||
* `err` - _String_ / null - Is null if no error occurs during request. | ||
@@ -102,0 +102,0 @@ * `body` - _String_ - Response content |
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
6336
67