Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more

exFetch (Deno)

License

Heat Release - Latest Release - Pre
GitHub GitHub Stars | GitHub Total Downloads GitHub Latest Release Version (GitHub Latest Release Date) GitHub Latest Pre-Release Version (GitHub Latest Pre-Release Date)

A Deno module to extend fetch.

This project is inspired from:

๐ŸŒŸ Feature

  • Automatically retry with the response header Retry-After or the jitter based delay.
  • Simplify paginate requests.

๐Ÿ““ Documentation (Excerpt)

For the full documentation, please visit the GitHub Repository Wiki.

Getting Started

  • Deno >= v1.35.0
    • allow-net (Allow Network Addresses): Resources Domain
/* Either */
import { ... } from "<URL>";// Named Import
import * as exFetch from "<URL>";// Namespace Import
import exFetch from "<URL>";// Default Import (Function `exFetch`)
Domain / Registry URL
Deno Land https://deno.land/x/exfetch[@<Tag>]/mod.ts
DenoPKG https://denopkg.com/hugoalh-studio/exfetch-deno[@<Tag>]/mod.ts
GitHub Raw * https://raw.githubusercontent.com/hugoalh-studio/exfetch-deno/<Tag>/mod.ts
Pax https://pax.deno.dev/hugoalh-studio/exfetch-deno[@<Tag>]/mod.ts

*: Must provide a tag.

API

Class

  • ExFetch

Function

  • exFetch
  • exFetchPaginate

Interface / Type

  • ExFetchEventName
  • ExFetchEventOnRetryPayload
  • ExFetchOptions
  • ExFetchPaginateOptions
  • ExFetchRetryOptions

Example

  • let responses: Response[] = await exFetchPaginate("https://api.github.com/repos/microsoft/vscode/labels?per_page=100");
    
    responses.map((response: Response) => {
      return response.ok;
    }).includes(false);
    //=> false (`false` when no broken page, otherwise `true`)
    
    let result = [];
    for (let response in responses) {
      result = await response.json();
    }
    result;
    /*=>
    [
      {
        "id": 2339554941,
        "node_id": "MDU6TGFiZWwyMzM5NTU0OTQx",
        "url": "https://api.github.com/repos/microsoft/vscode/labels/:apple:%20si",
        "name": ":apple: si",
        "color": "e99695",
        "default": false,
        "description": "Issues related to apple silicon"
      },
      {
        "id": 421131022,
        "node_id": "MDU6TGFiZWw0MjExMzEwMjI=",
        "url": "https://api.github.com/repos/microsoft/vscode/labels/*as-designed",
        "name": "*as-designed",
        "color": "E2A1C2",
        "default": false,
        "description": "Described behavior is as designed"
      },
      {
        "id": 409283388,
        "node_id": "MDU6TGFiZWw0MDkyODMzODg=",
        "url": "https://api.github.com/repos/microsoft/vscode/labels/*caused-by-extension",
        "name": "*caused-by-extension",
        "color": "E2A1C2",
        "default": false,
        "description": "Issue identified to be caused by an extension"
      },
      {
        "id": 766755777,
        "node_id": "MDU6TGFiZWw3NjY3NTU3Nzc=",
        "url": "https://api.github.com/repos/microsoft/vscode/labels/*dev-question",
        "name": "*dev-question",
        "color": "E2A1C2",
        "default": false,
        "description": "VS Code Extension Development Question"
      },
      {
        "id": 366106217,
        "node_id": "MDU6TGFiZWwzNjYxMDYyMTc=",
        "url": "https://api.github.com/repos/microsoft/vscode/labels/*duplicate",
        "name": "*duplicate",
        "color": "E2A1C2",
        "default": false,
        "description": "Issue identified as a duplicate of another issue(s)"
      },
      ... +467
    ]
    */