Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@empiricalrun/fetch

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@empiricalrun/fetch

This module provides a fetch instance wrapper designed to handle retries and timeouts seamlessly. It offers the following features:

  • 0.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

fetch

This module provides a fetch instance wrapper designed to handle retries and timeouts seamlessly. It offers the following features:

  • Retries: Specify the number of retries for failed requests. Default is set to 3.
  • Timeout: Set a timeout duration (in milliseconds) for requests. By default, there is no timeout.
  • Retry Condition: Define a custom function to determine whether a retry should be attempted. Installation

ou can install this module via npm:

npm install @empiricalrun/fetch

Usage

import {fetchWithRetry} from "@empiricalrun/fetch";

// Define shouldRetryFunction
function shouldRetry(response) {
    // Define your retry condition logic here
    return true;
}

// Usage example
const resp = await fetchWithRetry("<path>", { maxRetries: 2, timeout: 4000, shouldRetry });
const data = await resp.json();

Note: if the retry count has reached max value then shouldRetry cannot be called

FAQs

Package last updated on 25 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc