Registry / devops / effect-fetch

effect-fetch

JSON →
library2.2.0jsnpmunverified

Type-safe HTTP client for the Effect ecosystem, v2.2.0. Wraps the Fetch API with interceptors, strongly typed errors, and timeout support. Requires effect >=3.5.7 as a peer dependency. Ships TypeScript types. Differentiates from alternatives like axios or ky by integrating natively with Effect's structured concurrency and error management, enabling composable, type-safe HTTP pipelines with minimal boilerplate. Interceptors include base URL, timeout, logging, status filtering, and authentication. Actively maintained on GitHub.

npm install effect-fetch
INSTALL
IMPORT
SIG · EFFECT-FETCH
E
effect-fetch
devopsjavascriptv2.2.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.

* as Fetch
import * as Fetch from 'effect-fetch/Fetch'
import fetch from 'effect-fetch'; // Wrong: not a default export
Use named import 'Fetch' from the 'effect-fetch/Fetch' module. The package uses explicit module paths.
* as Result
import * as Result from 'effect-fetch/Response'
import { Response } from 'effect-fetch'; // Wrong: no default or named Response export
The Response module is imported from 'effect-fetch/Response'. Do not use 'effect-fetch' alone.
* as Interceptor
import * as Interceptor from 'effect-fetch/Interceptor'
const Interceptor = require('effect-fetch/Interceptor'); // Wrong: ESM-only package
Package is ESM-only. CommonJS require will not work. Use dynamic import if needed.
* as Adapter
import * as Adapter from 'effect-fetch/Adapters/Fetch'
import { fetch as adapter } from 'effect-fetch'; // Wrong: incorrect path
The Fetch adapter is imported from 'effect-fetch/Adapters/Fetch'. Not from the main entry.

Shows setup with base URL interceptor, fetch request, status filtering, and JSON decoding using Effect's structured concurrency.

import * as Effect from 'effect/Effect'; import * as Fetch from 'effect-fetch/Fetch'; import * as Result from 'effect-fetch/Response'; import * as Interceptor from 'effect-fetch/Interceptor'; import * as Adapter from 'effect-fetch/Adapters/Fetch'; import { BaseURL } from 'effect-fetch/interceptors/Url'; // Create an interceptor stack with a base URL const interceptors = Interceptor.of(BaseURL('https://api.example.com')); const interceptor = Interceptor.provide( Interceptor.make(interceptors), Adapter.fetch ); const adapter = Fetch.effect(interceptor); // Use Effect.gen to compose requests const program = Effect.gen(function* () { const result = yield* Fetch.fetch('/users'); const res = yield* Result.filterStatusOk(result); const users = yield* Result.json(res); return users; }); // Run the program with the adapter const users = await Effect.runPromise( Effect.provide(program, adapter) ); console.log(users);
Debug
Known issues
breakingIn version 2.0.0, the package was rewritten to be ESM-only. CommonJS require() will throw.
fix
Ensure your project uses ESM (type: 'module' in package.json) or use dynamic import().
affects: >=2.0.0
breakingStarting v2.0.0, main exports moved to subpath exports (e.g., 'effect-fetch/Fetch', 'effect-fetch/Response'). Importing from 'effect-fetch' alone will not work.
fix
Import from specific module paths like 'effect-fetch/Fetch' or 'effect-fetch/Response'.
affects: >=2.0.0
deprecatedInterceptor.Chain is deprecated in favor of Interceptor.provide with Interceptor.make pattern.
fix
Use Interceptor.make and Interceptor.provide as shown in the README.
affects: >=1.5.0
gotchaEffect must be >=3.5.7. Older versions of Effect will cause type errors or runtime failures.
fix
Update effect to >=3.5.7 in your package.json.
affects: >=2.0.0
gotchaThe 'effect' package is a peer dependency and must be installed separately. Not bundled.
fix
Run npm install effect alongside effect-fetch.
affects: >=1.0.0
gotchaInterceptor order matters: top-to-bottom execution. Misordering can cause unexpected behavior (e.g., logging before auth).
fix
Verify interceptor order: base URL first, then auth, then status filter, etc.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'effect-fetch' or its corresponding type declarations.
Importing from main entry 'effect-fetch' instead of subpath modules.
fix
Use import * as Fetch from 'effect-fetch/Fetch';
TypeError: effect_fetch_Fetch__default is not a function
Using default import instead of named import.
fix
Change to import * as Fetch from 'effect-fetch/Fetch'; then use Fetch.fetch(...).
SyntaxError: Cannot use import statement outside a module
Package is ESM-only and being used in a CommonJS context.
fix
Add "type": "module" to package.json or use dynamic import().
TypeError: Response.filterStatusOk is not a function
Importing from wrong module; filterStatusOk is in 'effect-fetch/Response'.
fix
Import * as Result from 'effect-fetch/Response'; then Result.filterStatusOk(...).
Upgrade
Version history
2.2.0latest on npm
Audit
Dependencies
effectrequiredRequired peer dependency. Provides Effect, Effect.gen, and other core types.
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
effect-fetch — npm install effect-fetch · libregistry