New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

response-iterator

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

response-iterator

Creates an async iterator for a variety of inputs in the browser and node. Supports fetch, node-fetch, and cross-fetch


Version published
Weekly downloads
2.1M
increased by1.29%
Maintainers
1
Weekly downloads
 
Created

response-iterator

Creates an async iterator for a variety of inputs in the browser and node. Supports fetch, node-fetch, cross-fetch, axios, got, undici.

Example 1

// import "isomorphic-fetch"; // node only
import responseIterator from "response-iterator";

const res = await fetch("https://raw.githubusercontent.com/kmalakoff/response-iterator/master/package.json");

let data = "";
for await (const chunk of responseIterator(res)) {
  data += chunk;
}
console.log(JSON.parse(data).name); // "response-iterator"

Example 2

import crossFetch from "cross-fetch";
import responseIterator from "response-iterator";

const res = await crossFetch("https://raw.githubusercontent.com/kmalakoff/response-iterator/master/package.json");

let data = "";
for await (const chunk of responseIterator(res)) {
  data += chunk;
}
console.log(JSON.parse(data).name); // "response-iterator"

Documentation

API Docs

FAQs

Package last updated on 23 Jun 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