Registry / storage / log-fetch

log-fetch

JSON →
library24.0.1jsnpmunverified

A Fetch API implementation for the Dat SDK (Hypercore) enabling p2p content loading from hyper:// URLs. Version 24.0.1, actively maintained on GitHub. Supports HEAD, GET, POST, DELETE methods with custom headers like X-Copy, X-Timer, X-Opt for drive management. Differentiates by providing a familiar fetch interface for decentralized storage.

npm install log-fetch
INSTALL
IMPORT
SIG · LOG-FETCH
L
log-fetch
storagejavascriptv24.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.

default
import fetch from 'log-fetch'
import { fetch } from 'log-fetch'
Default export only; named import will not work.
FetchInit
import type { FetchInit } from 'log-fetch'
Type import for TypeScript, does not exist as runtime value.
LogFetchError
import { LogFetchError } from 'log-fetch'
const LogFetchError = require('log-fetch').LogFetchError
Named export available for error type.

Demonstrates basic GET request to user's drive with timeout header using log-fetch.

import fetch from 'log-fetch' import { KeyPair } from 'dat-sdk' const sdk = new KeyPair() const response = await fetch('hyper://_/path/to/file', { method: 'GET', headers: { 'X-Timer': '5000' } }) console.log(response.status) const body = await response.text() console.log(body)
Debug
Known issues
gotchaX-Copy header only works with HEAD method; using it with GET will be ignored.
fix
Ensure X-Copy header is only used for HEAD requests.
affects: >=1.0.0
deprecatedX-Timer header expects a stringified number; passing a number will cause silent failure.
fix
Convert timer value to string: 'X-Timer': String(5000).
affects: >=20.0.0
gotchaHyperdrive key as hostname must be a valid 32-byte hex key; invalid keys lead to runtime error.
fix
Ensure key is a 64-character hex string representing 32 bytes.
affects: >=1.0.0
breakingRemoved support for deprecated dat:// URLs; now only hyper:// is accepted.
fix
Replace dat:// with hyper:// in URLs.
affects: >=24.0.0
Errors
Common errors & fixes
Error: Invalid argument: 'hostname' must be a valid public key
Hostname not recognized as a valid hyperdrive key or '_'.
fix
Use either '_' for user's drive or a 64-char hex string as hostname.
TypeError: Failed to fetch
Network error or invalid hyper:// URL.
fix
Verify the hyper:// URL is correctly formatted and the peer is online.
ReferenceError: fetch is not defined
Default import used as named import.
fix
Use import fetch from 'log-fetch' instead of import { fetch }.
Upgrade
Version history
24.0.1latest on npm
Audit
Dependencies
@effect/schemarequiredUsed for schema validation of response bodies
dat-sdkrequiredCore dependency for Dat protocol operations
Agent activity
20 hits · last 30 days
node
20
Resources
log-fetch — npm install log-fetch · libregistry