Registry / storage / closure-fetch

closure-fetch

JSON →
library0.4.2jsnpmunverified

A minimal fetch implementation designed for compatibility with Google Closure Compiler. Version 0.4.2 provides a subset of the Fetch API specifically for sending ArrayBuffer and plain strings, with response support limited to array buffers. It is intended for use in Closure Compiler-compiled projects where a lightweight, limited fetch wrapper is needed. The library has no active maintenance or release cadence, and lacks full Fetch API coverage (e.g., no JSON, text, or blob responses). Not recommended for general use; consider using the native Fetch API or a polyfill like unfetch or node-fetch for broader compatibility.

npm install closure-fetch
INSTALL
IMPORT
SIG · CLOSURE-FETCH
C
closure-fetch
storagejavascriptv0.4.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fetch
import { fetch } from 'closure-fetch';
import fetch from 'closure-fetch';
The library exports a named `fetch` function, not a default export.
fetch (CommonJS)
const { fetch } = require('closure-fetch');
const fetch = require('closure-fetch');
CommonJS require must destructure the named export.
Request
import { Request } from 'closure-fetch';
Request is also exported for use with Closure Compiler.

Shows basic usage of fetch to retrieve a binary file as ArrayBuffer, the only supported response type.

import { fetch } from 'closure-fetch'; fetch('/myfile.zip') .then(response => response.arrayBuffer()) .then(buffer => { console.log('Received buffer:', buffer); }) .catch(error => { console.error('Fetch failed:', error); });
Debug
Known issues
gotchaOnly supports ArrayBuffer responses. Methods like response.json(), response.text(), response.blob() are not available and will throw or return undefined.
fix
Use response.arrayBuffer() and manually parse if needed, or switch to a full fetch polyfill.
affects: >=0.0.0
gotchaRequest body must be ArrayBuffer or string. Sending JSON objects or FormData will fail.
fix
Convert body to string (e.g., JSON.stringify) or ArrayBuffer before sending.
affects: >=0.0.0
deprecatedThis package is no longer maintained. No updates or bug fixes are expected.
fix
Migrate to a maintained fetch implementation like unfetch or node-fetch.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: response.json is not a function
closure-fetch only provides response.arrayBuffer(), not the full fetch API.
fix
Use response.arrayBuffer() instead. If you need JSON, manually parse the buffer.
Cannot find module 'closure-fetch'
The package may not be installed or is not in node_modules.
fix
Run 'npm install closure-fetch' and ensure your import path is correct.
Upgrade
Version history
0.4.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
22
Resources
closure-fetch — npm install closure-fetch · libregistry