Socket
Socket
Sign inDemoInstall

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


Version published
Weekly downloads
1.7M
decreased by-3.31%
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 01 Nov 2020

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