Catalog npm
PACKAGE EXPLORERView in registry

@0xbeejs/fetch

npm

Provides an interface for fetching resources, base on [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).

0xbeejsfetch
Versions collected2
Direct dependencies18From release 0.0.2
Last observed20 Oct, 22:42 UTC

README

Current package documentation

@0xbeejs/fetch

Provides an interface for fetching resources, base on Fetch API.

Fetures

  • Supports Node.js and browsers
  • Supports specifying a timeout.
  • Supports specifying a proxy.

Installation

$ yarn add @0xbeejs/fetch

Usage

fetch

import fetch from "@0xbeejs/fetch";


function fetchWithTimeout() {
    const timeout = 15000; // 15s
    return fetch("http://www.google.com", {
        // optional
        proxyUrl: "http://127.0.0.1:7890",
    }, timeout)
}


const rsp = await fetchWithTimeout()

console.log(await rsp.text())

faithfulRequest

Execute a specific asynchronous action until timeout, supporting automatic retries, specifying the number of retries, and retry conditions.

import fetch from "@0xbeejs/fetch";


function fetchWithTimeout() {
    const timeout = 15000; // 15s
    return fetch("http://www.google.com", {
        // optional
        proxyUrl: "http://127.0.0.1:7890",
    }, timeout)
}

const resp = await faithfulRequest({
    req: () => fetchWithTimeout(),
    id: "get_google_homepage",
    // Optional. The assertion is true, and it will continue retrying until the maximum number of attempts is reached.
    maxRetries: -1, // -1: no limit,
    // Optional
    assert: (ex) => ex.name === "timeout" // 'true' will retry util reach the 'maxRetries'
    // Optional, how long to wait before starting the next request
})

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 2

Collected releases
VersionPublishedDirect dependenciesOpen version
0.0.2Registry latest25 Dec 202418
0.0.124 Dec 202418

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:42 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:214dd27b368a4bc90a0d1f0ca31d0a53e33452c00639d7b7c199028875e98d86