Registry / devops / bare-fetch

bare-fetch

JSON →
library3.0.1jsnpmunverified

WHATWG Fetch implementation for Node.js Bare, providing a lightweight, standards-compatible HTTP client for Bare environments. Version 3.0.1 is current, with active development on GitHub. It supports Request, Response, and Headers classes, automatic redirects, abort signals, and form data handling. Unlike node-fetch, it is designed specifically for Bare and uses bare-buffer and bare-abort-controller as peer dependencies. No external runtime dependencies beyond those.

npm install bare-fetch
INSTALL
IMPORT
SIG · BARE-FETCH
B
bare-fetch
devopsjavascriptv3.0.1
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
const fetch = require('bare-fetch')
import fetch from 'bare-fetch'
CJS-only. Default export is fetch function. ESM import not supported.
Request
const { Request } = require('bare-fetch')
const Request = require('bare-fetch').Request
Named export, not a property of default export.
Response
const { Response } = require('bare-fetch')
const Response = require('bare-fetch').Response
Named export.
Headers
const { Headers } = require('bare-fetch')
const Headers = require('bare-fetch').Headers
Named export.

Demonstrates basic GET request, checking response status, and parsing JSON body.

const fetch = require('bare-fetch') async function main() { const res = await fetch('https://jsonplaceholder.typicode.com/todos/1', { method: 'GET', headers: { 'Content-Type': 'application/json' } }) if (res.ok) { const data = await res.json() console.log(data) } else { console.error('Request failed with status', res.status) } } main().catch(console.error)
Debug
Known issues
gotchaRequires 'bare-abort-controller' and 'bare-buffer' as peer dependencies; not installing them will cause runtime errors.
fix
Run 'npm install bare-abort-controller bare-buffer' alongside bare-fetch.
affects: >=3.0.0
gotchaThe maximum number of redirects is hard-coded to 20; requests may fail with excessive redirects.
fix
Handle redirect manually or avoid URLs with more than 20 redirects.
affects: >=3.0.0
gotchaThis package is designed for Bare environments (like Bun or Node.js with bare-compatible runtimes). It may not work in standard Node.js without polyfills.
fix
Use in a Bare-compatible runtime or consider node-fetch for standard Node.
affects: >=3.0.0
breakingIn version 3.x, the API changed from default export of fetch to named exports for Request, Response, Headers. Older require patterns may break.
fix
Use const fetch = require('bare-fetch') and const { Request, Response, Headers } = require('bare-fetch').
affects: >=3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'bare-abort-controller'
Peer dependency 'bare-abort-controller' is missing.
fix
npm install bare-abort-controller
TypeError: fetch is not a function
CommonJS require returns an object with a 'fetch' property in older versions, but should be used as default export.
fix
Use const fetch = require('bare-fetch') correctly. Also ensure you have the right version (v3+).
TypeError: request.buffer is not a function
Body methods like buffer() are only available after a request is made, not on a Request object pre-fetch.
fix
Call buffer() on the Response object, e.g., const data = await res.buffer().
Upgrade
Version history
3.0.1latest on npm
Audit
Dependencies
bare-abort-controllerrequiredRequired to support abort signals (AbortController) for request cancellation.
bare-bufferrequiredRequired for buffer operations like request.buffer() and response.buffer().
Agent activity
20 hits · last 30 days
node
16
Amazon
1
OpenAI (training)
1
Resources
bare-fetch — npm install bare-fetch · libregistry