ziti-electron-fetch

2.6.31 • Public • Published

ziti-electron-fetch

npm version build status install size

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

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

Package Sidebar

Install

npm i ziti-electron-fetch

Weekly Downloads

38

Version

2.6.31

License

Apache-2.0

Unpacked Size

424 kB

Total Files

8

Last publish

Collaborators

  • ctudornetfoundry