pull-fetch
A pull-stream HTTP client for Node.js
Install
npm i pull-fetch
Usage
fetch(options)
Make an HTTP request. Options are the same as http.request
. If it HTTPS it will switch the function.
Returns a pull-stream
sink that reads data for the request. If the request has not body (e.g. a GET request) then function returned can be called with nothing to proceed with the response.
Then the stream returns a promise that resolves into a response object. It contains any property http.IncomingMessage
has, plus source
for streaming the response data as a pull-stream
source
const response = await console responsesource
Or with no body:
const response = await console responsesource
Combining pull-streams and promises give an intuitive way to handle the requests. There is little to no overhead with Node's APIs.