• Specify the behaviour of a network request.

    • default: Requests are automatically retried, and are subject to automatic cancellation if they're taking too long. This is generally desirable.
    • non-blocking: Requests are not retried if they fail with a network error, and are automatically cancelled if they're taking too long. This is good for throwaway requests, like polling or tracking.
    • slow-request: Requests are not retried if they fail with a network error, and are not automatically cancelled. This is good for slow requests that should be give the chance to complete, and are unlikely to be safe to retry.

    Some request behaviours may be de-activated by the environment, and this function takes care of that concern. You can also provide a customised request behaviour.

    Parameters

    • preset: RequestModeInput = 'default'

      The preset to use.

    • env: ProcessEnv = process.env

      Process environment variables.

    Returns RequestBehaviour

    A request behaviour object.