Registry / devops / node-fetch-core

node-fetch-core

JSON →
library1.0.0jsnpmunverified

A lightweight core set of fetch utilities optimized for Node.js environments, version 1.0.0. Provides a minimal, dependency-light implementation of the Fetch API spec tailored for server-side use, with support for streaming, timeouts, and custom agents. Differentiates from full-featured libraries like node-fetch by focusing on a lean core for building custom fetch wrappers.

npm install node-fetch-core
INSTALL
IMPORT
SIG · NODE-FETCH-CORE
N
node-fetch-core
devopsjavascriptv1.0.0
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.

default
import fetchCore from 'node-fetch-core'
const fetchCore = require('node-fetch-core');
This package is ESM-only. CommonJS require will fail unless using dynamic import().
RequestInit
import type { RequestInit } from 'node-fetch-core'
import { RequestInit } from 'node-fetch-core';
Use 'import type' for type imports in TypeScript to avoid runtime errors.
AbortError
import { AbortError } from 'node-fetch-core'
import AbortError from 'node-fetch-core';
AbortError is a named export, not default.

Shows how to make a fetch request with timeout using AbortController.

import fetchCore from 'node-fetch-core'; import { AbortController } from 'node-fetch-core'; // or from 'abort-controller' if not bundled async function getData() { const controller = new AbortController(); const timeout = setTimeout(() => controller.abort(), 5000); try { const response = await fetchCore('https://api.example.com/data', { signal: controller.signal }); const data = await response.json(); console.log(data); } catch (err) { if (err.name === 'AbortError') { console.error('Request timed out'); } else { console.error(err); } } finally { clearTimeout(timeout); } } getData();
Debug
Known issues
gotchaThis package is ESM-only. Using require() will throw an error. Use dynamic import() or configure your project for ESM.
fix
Use import() syntax or set "type": "module" in your package.json.
affects: >=1.0.0
breakingAbortController is not included by default in Node.js <15. You may need to polyfill it.
fix
Install 'abort-controller' polyfill for Node.js <15 or upgrade Node.
affects: >=1.0.0
gotchaThe returned Response object does not support .body (readable stream) in Node.js <18 without additional polyfill.
fix
Use response.buffer() or response.text() instead, or ensure Node.js >=18.
affects: >=1.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Using require() on an ESM-only package.
fix
Switch to import() or set "type": "module" in package.json.
TypeError: AbortController is not a constructor
Missing polyfill for AbortController in older Node.js versions.
fix
Install 'abort-controller' with npm install abort-controller and import it.
TypeError: response.body is undefined
Trying to access .body (ReadableStream) in Node.js <18.
fix
Use response.buffer() or response.text() for reading the response.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
node-fetch-core — npm install node-fetch-core · libregistry