Ultra-simple, lightweight, dependency-free Node.JS HTTP request client (with util.promisify support)
Full documentation | GitHub | NPM
For a simple page GET request.
var p = require("phin");
p("https://www.github.com/Ethanent", (err, res) => {
if (!err) console.log(res.body.toString());
});
npm install phin
p({
"url": "https://www.github.com/Ethanent",
"headers": {
"User-Agent": "phin"
}
});
p({
"url": "https://www.github.com/Ethanent",
"method": "POST",
"port": 8080,
"data": {
"name": "John Doe",
"someKey": "someValue"
},
"headers": {
"Content-Type" : "application/json"
}
}, (err, res) => {
if (!err) console.log("Sent data!");
});
p({
"url": "https://example.com",
"auth": "ethan:letmein"
}, (err, res) => {
if (!err) console.log(res.body);
});
p({
"url": "https://ethan:[email protected]:8080"
}, (err, res) => {
if (!err) console.log(res.body);
});
Note that phin
has util.promisify
support.