Socket
Socket
Sign inDemoInstall

minipass-fetch

Package Overview
Dependencies
7
Maintainers
6
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    minipass-fetch

An implementation of window.fetch in Node.js using Minipass streams


Version published
Weekly downloads
17M
decreased by-1.09%
Maintainers
6
Install size
912 kB
Created
Weekly downloads
 

Package description

What is minipass-fetch?

The minipass-fetch npm package is a light-weight implementation of the window.fetch API built on top of the minipass stream library. It is designed to be a smaller, stream-based alternative to the larger fetch implementations, allowing for efficient data handling and manipulation in Node.js environments.

What are minipass-fetch's main functionalities?

Performing HTTP GET requests

This feature allows you to perform HTTP GET requests to retrieve data from a specified URL. The response can be processed as JSON.

const fetch = require('minipass-fetch');

fetch('https://api.example.com/data')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

Performing HTTP POST requests

This feature allows you to perform HTTP POST requests to send data to a server. You can include headers and a body in the request.

const fetch = require('minipass-fetch');

fetch('https://api.example.com/submit', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ key: 'value' })
})
.then(response => response.json())
.then(data => console.log('Success:', data))
.catch(error => console.error('Error:', error));

Streaming response data

This feature leverages the streaming capabilities of minipass-fetch to handle large amounts of data without buffering it all in memory at once.

const fetch = require('minipass-fetch');
const { PassThrough } = require('stream');

fetch('https://api.example.com/large-data')
  .then(response => {
    const stream = new PassThrough();
    response.body.pipe(stream);
    stream.on('data', chunk => console.log(chunk.toString()));
  })
  .catch(error => console.error('Error:', error));

Other packages similar to minipass-fetch

Changelog

Source

3.0.4 (2023-08-14)

Dependencies

  • 69e9e53 #114 bump minipass from 5.0.0 to 7.0.3

Readme

Source

minipass-fetch

An implementation of window.fetch in Node.js using Minipass streams

This is a fork (or more precisely, a reimplementation) of node-fetch. All streams have been replaced with minipass streams.

The goal of this module is to stay in sync with the API presented by node-fetch, with the exception of the streaming interface provided.

Why

Minipass streams are faster and more deterministic in their timing contract than node-core streams, making them a better fit for many server-side use cases.

API

See node-fetch

Differences from node-fetch (and, by extension, from the WhatWG Fetch specification):

Keywords

FAQs

Last updated on 14 Aug 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc