JSPM

  • Created
  • Published
  • Downloads 1982975
  • Score
    100M100P100Q189853F
  • License SEE LICENSE IN LICENSE.md

Ultra-simple, lightweight, dependency-free Node.JS HTTP request client

Package Exports

  • phin

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (phin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.