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.
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.
Whenever a timeout occurs, this callback is executed.