Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

phin

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

phin

The ultra-lightweight Node.js HTTP client

  • 3.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6M
decreased by-1.76%
Maintainers
1
Weekly downloads
 
Created

What is phin?

The phin npm package is a lightweight HTTP client designed for simplicity and minimalism. It is used for making HTTP requests from Node.js environments. It supports promises and can handle various types of requests such as GET, POST, and more.

What are phin's main functionalities?

Simple HTTP GET requests

This code sample demonstrates how to perform a simple HTTP GET request to a specified URL using phin.

const phin = require('phin')

phin('https://example.com', (err, res) => {
  if (err) throw err
  console.log(res.body)
})

HTTP POST requests with JSON

This code sample shows how to perform an HTTP POST request with JSON data using phin.

const phin = require('phin')

const options = {
  url: 'https://example.com/post',
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  data: { key: 'value' }
}

phin(options, (err, res) => {
  if (err) throw err
  console.log(res.body)
})

Promisified HTTP requests

This code sample illustrates how to use phin with promises to make asynchronous HTTP requests.

const phin = require('phin').promisified

async function makeRequest() {
  try {
    const res = await phin('https://example.com')
    console.log(res.body)
  } catch (err) {
    console.error(err)
  }
}

makeRequest()

Other packages similar to phin

Keywords

FAQs

Package last updated on 16 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc