Skip to Content

Examples

Find a complete program that uses Effetch, typechecked with the package.

The guides show one feature at a time. When you want to see several of them working together in a whole program, look in the repository's examples/ folder.

The examples are typechecked with the package on the main branch, which can be ahead of the latest release. To read them as they were at your version, switch GitHub's branch menu to that release's tag, such as v0.1.0-rc.4.

The folder has these programs:

  • basic.ts: a client in a service, the methods, and handling each error.
  • builtins.ts: the built-in plugins, and changing them for one call.
  • plugins.ts: writing plugins, from auth with a service to a wrap with its own error.
  • endpoints.ts: the same app as builtins.ts, with endpoints.
  • backends.ts: two backends in one file, with shared plugins.
  • status-errors.ts: your own errors by status, for every call, per endpoint and for one call.
  • streams.ts: Server-Sent Events, newline-delimited JSON, and a list paged through by its Link header.
  • testing.ts: tests for the app/ todos module, against a fake backend made from its endpoints.
  • app/: a feature-sliced app, with clients as shared infrastructure and each module defining its own endpoints.

The examples' README walks through each one, and explains how app/ is laid out.

What's next

On this page