ziti-electron-fetch
v2.6.31
Published
A module that intercepts all window.fetch calls in an Electron renderer process and routes them over a Ziti network
Downloads
94
Maintainers
Readme
ziti-electron-fetch
A module that intercepts all window.fetch
calls in the web-app loaded within an Electron Renderer process, and routes those HTTP/REST calls over a Ziti network.
- Motivation
- Features
- Difference from client-side fetch
- Installation
- Loading and configuring the module
- License
- Acknowledgement
Motivation
Instead of implementing XMLHttpRequest
in Node.js to run browser-specific Fetch polyfill, why not go from native http
to fetch
API directly? Hence, ziti-electron-fetch
, minimal code for a window.fetch
compatible API on Node.js runtime.
Features
- Stay consistent with
window.fetch
API. - Make conscious trade-off when following WHATWG fetch spec and stream spec implementation details, document known differences.
- Use native promise but allow substituting it with [insert your favorite promise library].
- Use native Node streams for body on both request and response.
- Useful extensions such as timeout, redirect limit, response size limit, explicit errors for troubleshooting.
Difference from client-side fetch
- See Known Differences for details.
- If you happen to use a missing feature that
window.fetch
offers, feel free to open an issue. - Pull requests are welcomed too!
Installation
$ npm install ziti-electron-fetch
Loading and configuring the module
We suggest you load the module via require
until the stabilization of ES modules in node:
const fetch = require('ziti-electron-fetch');
Acknowledgement
Thanks to node-fetch for providing a solid implementation reference.
License
Apache 2.0