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);
Errors
Common errors & fixes
Cannot find module 'effect-fetch' or its corresponding type declarations.
Importing from main entry 'effect-fetch' instead of subpath modules.
fixUse import * as Fetch from 'effect-fetch/Fetch';
TypeError: effect_fetch_Fetch__default is not a function
Using default import instead of named import.
fixChange 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.
fixAdd "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'.
fixImport * as Result from 'effect-fetch/Response'; then Result.filterStatusOk(...).
Audit
Dependencies
effectrequiredRequired peer dependency. Provides Effect, Effect.gen, and other core types.