Перейти к основному содержимому
Version: 3.5.x

Retry requests

You can use retry parameter to retry your request number of times if it failed.

Request on example below will make three attempts to request the data, If it fails on 3rd try - the errror response will be provided

You need to know that the retry parameter is binded with the timeoutValue parameter (see timeoutValue example)

|-------timeoutValue--------|

|--retry1--retry2--retry3--|

import Joi from "joi";
import { RestRequest, IResponse } from "@mihanizm56/fetch-api";

export const getWhateverRequest = (someData): Promise<IResponse> =>
  new RestRequest().getRequest({
    endpoint: "http://localhost:3000",
    responseSchema: Joi.object({
      test_string_field: Joi.string().required(),
    }),
    retry: 3,
  });