Skip to content

evandro-zanatta-vindi/phin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

phin logo


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

Full documentation | GitHub | NPM

Discord logo Chat on Discord

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:[email protected]:8080"
}, (err, res) => {
	if (!err) console.log(res.body);
});

Documentation

See the phin documentation.

Note that phin has util.promisify support.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published