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

nodeify-fetch

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodeify-fetch

Node streams for fetch

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

nodeify-fetch

build status npm version

The nodeify-fetch package provides a Node.js Readable stream interface for fetch. In the browser, the built-in fetch is used. In a Node.js environment, node-fetch it's used.

Since version 3.0, this packages is ESM only. Check version 2.x if you are looking for a CommonJS package.

Usage

The only difference to the fetch standard is the .body property. nodeify-fetch patches the .body to a readable stream:

import { promisify } from 'util'
import fetch from 'nodeify-fetch'
import { finished } from 'readable-stream'

async function main () {
  const res = await fetch('http://worldtimeapi.org/api/timezone/etc/UTC')

  if (!res.ok) {
    console.log(`error ${res.statusText}(${res.status})`)
  }

  res.body.on('data', chunk => console.log(chunk.toString()))

  await promisify(finished)(res.body)
}

main()

Keywords

FAQs

Package last updated on 02 Oct 2022

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