Home

phin

Ultra-simple, lightweight, dependency-free Node.JS HTTP request client (with util.promisify support)

phin logo


Full documentation | GitHub | NPM

Simple Usage

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());
});

Installation

npm install phin

Quick Demos

GET request with added headers

p({
    "url": "https://www.github.com/Ethanent",
    "headers": {
        "User-Agent": "phin"
    }
});

POST request with data

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!");
});

GET request with authorization using auth option

p({
    "url": "https://example.com",
    "auth": "ethan:letmein"
}, (err, res) => {
    if (!err) console.log(res.body);
});

GET request with authorization through url

p({
    "url": "https://ethan:letmein@example.com:8080"
}, (err, res) => {
    if (!err) console.log(res.body);
});

Documentation

See the phin documentation.

Note that phin has util.promisify support.