{"id":48671,"library":"nestjs-axios-retry","title":"NestJS Axios Retry","description":"A NestJS module (v1.0.7) that integrates axios-retry with NestJS's HttpModule, providing configurable retry logic for HTTP requests. It supports retry count, delay strategies (exponential backoff), custom retry conditions, and on-retry callbacks. Differentiates from manual axios-retry usage by offering a declarative NestJS module setup with forRoot configuration. Uses axios-retry v4 and requires @nestjs/common and @nestjs/core v10. Release cadence is low; last update 2023.","status":"active","version":"1.0.7","language":"javascript","source_language":"en","source_url":"https://github.com/malindaj/nestjs-axios-retry","tags":["javascript","nestjs","axios","http","retry","axios-retry","nestjs-module","typescript"],"install":[{"cmd":"npm install nestjs-axios-retry","lang":"bash","label":"npm"},{"cmd":"yarn add nestjs-axios-retry","lang":"bash","label":"yarn"},{"cmd":"pnpm add nestjs-axios-retry","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for retry functionality","package":"axios-retry","optional":false}],"imports":[{"note":"ESM-only; use named import. CommonJS require may not work due to ESM packaging.","wrong":"const AxiosRetryModule = require('nestjs-axios-retry').AxiosRetryModule","symbol":"AxiosRetryModule","correct":"import { AxiosRetryModule } from 'nestjs-axios-retry'"},{"note":"The package only exports a named AxiosRetryModule, no default export.","wrong":"import { default as AxiosRetryModule } from 'nestjs-axios-retry'","symbol":"AxiosRetryModule (default import)","correct":"import AxiosRetryModule from 'nestjs-axios-retry'"},{"note":"axios-retry v4 is ESM-only; default export. CommonJS require('axios-retry').default may be needed in some setups.","wrong":"import { axiosRetry } from 'axios-retry'","symbol":"axiosRetry (from axios-retry)","correct":"import axiosRetry from 'axios-retry'"},{"note":"HttpService is from @nestjs/axios, not from this package.","wrong":"import { HttpService } from 'nestjs-axios-retry'","symbol":"HttpService","correct":"import { HttpService } from '@nestjs/axios'"}],"quickstart":{"code":"import { Module } from '@nestjs/common';\nimport { AxiosRetryModule } from 'nestjs-axios-retry';\nimport axiosRetry from 'axios-retry';\n\n@Module({\n  imports: [\n    AxiosRetryModule.forRoot({\n      axiosRetryConfig: {\n        retries: 3,\n        retryDelay: axiosRetry.exponentialDelay,\n        retryCondition: (error) => error.response?.status === 429,\n        onRetry: (retryCount, error, requestConfig) => {\n          console.log(`Retry #${retryCount}`);\n        },\n      },\n    }),\n  ],\n})\nexport class AppModule {}\n\n// In a service:\nimport { Injectable } from '@nestjs/common';\nimport { HttpService } from '@nestjs/axios';\nimport { firstValueFrom } from 'rxjs';\n\n@Injectable()\nexport class AppService {\n  constructor(private httpService: HttpService) {}\n  async fetchData() {\n    const response = await firstValueFrom(\n      this.httpService.get('https://api.example.com/data')\n    );\n    return response.data;\n  }\n}","lang":"typescript","description":"Registers AxiosRetryModule with exponential backoff, 3 retries, and a condition to retry on HTTP 429. Then uses HttpService in a service."},"warnings":[{"fix":"Ensure axios-retry version is compatible (v4 recommended). If TypeScript errors, manually define config type.","message":"AxiosRetryConfig is typed inline; importing from 'axios-retry' may lose typing if the version mismatches.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use forRoot() only in root module. For feature modules, import the same forRoot configuration or use global module.","message":"AxiosRetryModule.forRoot() must be called; calling forFeature() is not supported for per-module configuration.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use axios-retry v4 (peer dependency). With v3, the config key is different ('retry' instead of 'axios-retry').","message":"The module does not support per-request retry config via 'axios-retry' key in AxiosRequestConfig if axios-retry v3 or lower is used.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update to v1.0.7 or later, or manually check peer version compatibility.","message":"Deprecated: The package's peer dependency on @nestjs/common ^10.1.2 may not work with NestJS v9.","severity":"deprecated","affected_versions":">=1.0.0 <1.0.7"},{"fix":"Upgrade axios-retry to v4. See migration guide for axios-retry v4 changes.","message":"Breaking: v1.0.0 removed support for older axios-retry versions; only v4 is supported.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Always use firstValueFrom() or lastValueFrom() to execute the HTTP call.","message":"The HttpService from @nestjs/axios returns Observables; forgetting to convert to Promise (firstValueFrom) will not run the request.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Specify all needed retry options in per-request config; module-level defaults are ignored.","message":"Per-request 'axios-retry' config may override module-level config completely; not merge.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'2023':74 'axio':2,11,44,59,77,81 'axios-retri':10,43,58,80 'backoff':31 'cadenc':69 'callback':39 'condit':34 'configur':18,56 'count':27 'custom':32 'declar':50 'delay':28 'differenti':40 'exponenti':30 'forroot':55 'http':22,78 'httpmodul':16 'integr':9 'javascript':75 'last':72 'logic':20 'low':71 'manual':42 'modul':6,52,85 'nestj':1,5,14,51,76,84 'nestjs-modul':83 'nestjs/common':64 'nestjs/core':66 'offer':48 'on-retri':36 'provid':17 'releas':68 'request':23 'requir':63 'retri':3,12,19,26,33,38,45,60,79,82 'setup':53 'strategi':29 'support':25 'typescript':86 'updat':73 'usag':46 'use':57 'v1.0.7':7 'v10':67 'v4':61","created_at":"2026-06-07T16:57:50.670504+00:00","updated_at":"2026-06-07T16:57:50.670504+00:00","problems":[{"fix":"Run npm install nestjs-axios-retry axios-retry && ensure tsconfig.json includes node_modules types.","cause":"Package not installed or missing TypeScript type declarations.","error":"Cannot find module 'nestjs-axios-retry' or its corresponding type declarations."},{"fix":"Use import axiosRetry from 'axios-retry'. If using CommonJS, use const axiosRetry = require('axios-retry').default.","cause":"Using commonjs require('axios-retry') incorrectly; axios-retry v4 is ESM-only.","error":"TypeError: axiosRetry.exponentialDelay is not a function"},{"fix":"Add null check: (error) => error.response?.status === 429.","cause":"retryCondition expects error.response to exist, but error may be network error without response.","error":"UnhandledPromiseRejectionWarning: TypeError: Cannot read properties of undefined (reading 'status')"},{"fix":"Import AxiosRetryModule and add it to imports array with forRoot() call.","cause":"AxiosRetryModule not imported or forRoot not called.","error":"Error: Nest can't resolve dependencies of the HttpService (*). Please make sure that the argument dependency at index [0] is available in the AppModule context."},{"fix":"Extend AxiosRequestConfig type with 'axios-retry' property, or cast to any: this.httpService.get(url, { 'axios-retry': {...} } as any)","cause":"TypeScript does not recognize the 'axios-retry' key in AxiosRequestConfig.","error":"No overload matches this call. Type '{ 'axios-retry': { ... } }' is not assignable to type 'AxiosRequestConfig'."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/malindaj/nestjs-axios-retry#readme","github":"https://github.com/malindaj/nestjs-axios-retry","docs":null,"changelog":null,"pypi":null,"npm":"nestjs-axios-retry","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}