Skip to content

Dependency injection of fetch implementation on node #8

@cspotcode

Description

@cspotcode

On node, is there a way to use dependency injection to provide a fetch implementation rather than declaring one globally? Is there a recommended implementation, maybe https://www.npmjs.com/package/isomorphic-fetch or https://www.npmjs.com/package/cross-fetch?

Ideally, I'd like to be able to do:

import {create} from 'gretchen';
import * as fetch from 'cross-fetch';
const gretch = create({fetch});
await gretch("/api/user/12").json();

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions