RequestOptions: {
    agent?: HttpAgent | HttpsAgent;
    cachePlugin?: Plugin;
    getCacheID?: (() => string);
    getExpiration?: ((url) => number | undefined);
    isCacheable?: ((url) => boolean | undefined);
    retries: number;
    shouldRetry?: SuperAgentCallbackHandler;
    timeout: number | Timeouts;
}

Options to configure a request.

Type declaration

  • Optional Readonly agent?: HttpAgent | HttpsAgent

    The agent to be used for the request.

  • Optional Readonly cachePlugin?: Plugin

    The superagent-cache-plugin instance that will be used.

  • Optional Readonly getCacheID?: (() => string)
      • (): string
      • Call to obtain a cache-safe identifier the currently handled request.

        This is used to identify the request when comparing with cached responses so that we can determine if a response was fulfilled from cache or from a fresh request.

        Without an implementation of this method, it is not possible to determine if something is from cache or not.

        Returns string

  • Optional Readonly getExpiration?: ((url) => number | undefined)
  • Optional Readonly isCacheable?: ((url) => boolean | undefined)
      • (url): boolean | undefined
      • A callback used to determine if a particular URL's result should be cached or not. This defaults to only allowing JS file extensions to be stored. This callback should return null for the default behavior to apply.

        Parameters

        • url: string

        Returns boolean | undefined

  • Readonly retries: number

    The number of times a request is retried if it fails from a transient error. This is in addition to the initial request. For example, if this were set to 3, then there could be a total of 4 requests. Note that for all GET requests made during server-side rendering, it is assumed they will be idempotent.

  • Optional Readonly shouldRetry?: SuperAgentCallbackHandler

    Callback invoked if a retry occurs. This should return null for the default behavior to apply, true to allow the retry, and false to block further retries.

    Returning a non-boolean value causes superagent to do its default behavior, which is:

    • allow retry for all 500 errors except 501
    • allow retry for err.code set to any: ['ECONNRESET', 'ETIMEDOUT', 'EADDRINFO', 'ESOCKETTIMEDOUT']
    • allow retry if err.timeout is truthy and err.code is 'ECONNABORTED`
    • allow retry if err.crossDomain is truthy
  • Readonly timeout: number | Timeouts

    Time to wait in milliseconds before a request times out.

Generated using TypeDoc