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

Options to configure a request.

Type declaration

  • Optional Readonlyagent?: HttpAgent | HttpsAgent

    The agent to be used for the request.

  • Optional ReadonlycachePlugin?: Plugin

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

  • Optional ReadonlygetCacheID?: () => 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.

  • Optional ReadonlygetExpiration?: (url: string) => number | undefined

    A callback to calculate when the cached response for a given URL should expire. If this method is omitted, the cache provider's default expiration will be used. The result is given to superagent-cache-plugin and works according to its documentation.

    https://github.com/jpodwys/superagent-cache-plugin/tree/02e41c5b98c89318133d4736b2bd1abcc1866bab

  • Optional ReadonlyisCacheable?: (url: string) => 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.

  • Readonlyretries: 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 ReadonlyshouldRetry?: 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
  • Readonlytimeout: number | Timeouts

    Time to wait in milliseconds before a request times out.