Skip to content

Latest commit

 

History

History
21 lines (16 loc) · 781 Bytes

timeout.md

File metadata and controls

21 lines (16 loc) · 781 Bytes

Timeout strategy

To create a timeout strategy we need to call our policy factory using the createTimeoutHttpExecutor method:

const timeoutPolicyExecutor =
  PolicyExecutorFactory.createTimeoutHttpExecutor({
    timeoutInMilli: 200,
    onTimeout: () => {
      console.log("A timeout has occurred.")
    }
  });

The createTimeoutHttpExecutor method takes a configuration object to properly configure the timeout policy.

timeoutInMilli

Whenever your request takes longer than the quantity specified in this property, a timeout error will be thrown under the error property on the result object.

(optional) onTimeout

Whenever a timeout occurs, this callback is executed.