/fetching

An enhanced fetch for Deno.

Primary LanguageTypeScript

🦚 fetching

GitHub Workflow Status Deno module Deno compatibility

An enhanced fetch for Deno.

Usage

import { createFetching } from "https://deno.land/x/fetching@v0.0.2/mod.ts";
import { prettyLog } from "https://deno.land/x/fetching@v0.0.2/lib/prettyLog.ts";

const fetching = createFetching({
  // The Cache API is supported
  cache: await caches.open("v1"),
  log: prettyLog,
  allowedOrigins: [{
    hostname: "httpbin.org",
  }],
});

// You can do this, or not
globalThis.fetch = fetching;

// This request will succeed!
await fetch("https://httpbin.org/get");

// This request will fail since we have not configured it as an allowedOrigin
await fetch("https://jsonplaceholder.typicode.com/todos/1");