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

parse-retry-after

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-retry-after

Parses an HTTP Retry-After header and returns delay time in seconds.

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Build Status License NPM Downloads Known Vulnerabilities Coverage Status

parse-retry-after

Parses an HTTP Retry-After header and returns delay time in seconds.

  • If there is no Retry-After header, returns 0
  • If there is, returns seconds to delay, rounding up, minimum 1
  • If Retry-After header is not an integer or a Date, (should not happen) throws an Error.

Usage (very rough, your code will differ!)

const parse_retry_after = require('parse-retry-after');  // or import...

fetch(URL, init)
  .then(function(response) {
    // probably want to save response somewhere somehow...
    // check response.status
    if (mightBeARetry) {
       let delaySeconds = parse_retry_after(response);
       if (delaySeconds) {
          //delay and call fetch again...
       }
    }
    else {
      // normal "happy path" code
    }
  })

Todos

  1. Currently uses module.exports, should probably use ES6 export
  • see parse-retry-after6.mjs for first pass at an ES6 export.

Keywords

FAQs

Package last updated on 10 May 2021

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