braid-protocol icon indicating copy to clipboard operation
braid-protocol copied to clipboard

Use node-web-streams

Open canadaduane opened this issue 3 years ago • 1 comments

The client can be used in the browser or in a nodejs process. We use two separate mechanisms to read the stream in each case. A potentially more elegant solution was identified here:

// On nodejs, this requires "npm install node-fetch node-web-streams"
if (typeof window === 'undefined') {
    var fetch = require('node-fetch')
    var Headers = fetch.Headers
    var to_whatwg_stream = require('node-web-streams').toWebReadableStream
    module.exports = braid_fetch
}

canadaduane avatar Mar 03 '21 16:03 canadaduane