Type alias CommonRequestOptions

CommonRequestOptions: {
    afterResponse?: ((err, res?) => void | Promise<void>);
    allowDirtyRead?: boolean;
    beforeRequest?: ((req) => void | Promise<void>);
    maxRetries?: false | number;
    retryOnConflict?: number;
    timeout?: number;
}

Options that can be shared globally for all requests made with arangojs.

Type declaration

  • Optional afterResponse?: ((err, res?) => void | Promise<void>)

    Callback that will be invoked when the server response has been received and processed or when the request has been failed without a response.

    The originating request will be available as the request property on either the error or response object.

      • (err, res?): void | Promise<void>
      • Parameters

        • err: NetworkError | null

          Error encountered when handling this request or null.

        • Optional res: globalThis.Response & {
              request: globalThis.Request;
          }

          Response object for this request, if no error occurred.

        Returns void | Promise<void>

  • Optional allowDirtyRead?: boolean

    Whether ArangoDB is allowed to perform a dirty read to respond to the request. If set to true, the response may reflect a dirty state from a non-authoritative server.

    Default: false

  • Optional beforeRequest?: ((req) => void | Promise<void>)

    Callback that will be invoked with the finished request object before it is finalized. In the browser the request may already have been sent.

      • (req): void | Promise<void>
      • Parameters

        • req: globalThis.Request

          Request object or XHR instance used for this request.

        Returns void | Promise<void>

  • Optional maxRetries?: false | number

    Determines the behavior when a request fails because the underlying connection to the server could not be opened (e.g. ECONNREFUSED in Node.js):

    • false: the request fails immediately.

    • 0: the request is retried until a server can be reached but only a total number of times matching the number of known servers (including the initial failed request).

    • any other number: the request is retried until a server can be reached or the request has been retried a total of maxRetries number of times (not including the initial failed request).

    When working with a single server, the retries (if any) will be made to the same server.

    This setting currently has no effect when using arangojs in a browser.

    Note: Requests bound to a specific server (e.g. fetching query results) will never be retried automatically and ignore this setting.

    Note: To set the number of retries when a write-write conflict is encountered, see retryOnConflict instead.

    Default: 0

  • Optional retryOnConflict?: number

    If set to a positive number, requests will automatically be retried at most this many times if they result in a write-write conflict.

    Default: 0

  • Optional timeout?: number

    Time in milliseconds after which arangojs will abort the request if the socket has not already timed out.