Registry / devops / axios-polling

axios-polling

JSON →
library1.1.1jsnpmunverified

Axios-polling is a library that extends Axios with polling capabilities, allowing you to create and manage polling requests with configurable retry limits, delays, and event handlers. Version 1.1.1 is stable, with an active release cadence. It requires Axios >=0.3 or >=1 and ships TypeScript types. Key differentiators include built-in retry logic, delay gaps, and event-based monitoring of request lifecycle.

npm install axios-polling
INSTALL
IMPORT
SIG · AXIOS-POLLING
A
axios-polling
devopsjavascriptv1.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

axiosPolling
import { axiosPolling } from 'axios-polling'
const axiosPolling = require('axios-polling')
ESM-only; CommonJS require is not supported by package.json exports.
default
import axiosPolling from 'axios-polling'
import { default as axiosPolling } from 'axios-polling'
Default export is available as the same function, but named export is preferred due to TypeScript types.
AxiosPollingConfig
import type { AxiosPollingConfig } from 'axios-polling'
import { AxiosPollingConfig } from 'axios-polling'
This is a TypeScript type only, so use 'import type' to avoid runtime errors.

Initializes axios-polling, creates a polling request, starts it, listens for responses, and stops after 10 seconds.

import axios from 'axios'; import { axiosPolling } from 'axios-polling'; // Initialize polling with options axiosPolling(axios, { retryLimit: 15 }); // Create a polling request const { emit, on, off, remove } = axios.poll({ url: '/api/data', params: { id: 1 }, delay: 2000 }); // Start polling emit(); // Listen for responses on('response', (response) => { console.log('Response:', response.data); }); // Stop polling after 10 seconds setTimeout(() => { off(); remove(); }, 10000);
Debug
Known issues
breakingaxios-polling version 1.0.0 changed the default export from an object to a function. Existing code using 'import axiosPolling from 'axios-polling'' may break if expecting an object.
fix
Update to version 1.1.0 or later, or change import to 'import { axiosPolling } from 'axios-polling''.
affects: >=1.0.0 <1.1.0
gotchaThe axiosPolling function must be called before using axios.poll(). If you call axios.poll() without initializing, it will throw 'axios.poll is not a function'.
fix
Always call axiosPolling(axios, config) before any axios.poll() calls.
affects: >=1.0.0
gotchaThe 'emit' function only sends the request once per call. It does not automatically retry on error; retry logic is handled internally based on config.
fix
Use 'emit()' to send each poll cycle. To stop polling, call 'off()' or 'remove()'.
affects: >=1.0.0
deprecatedThe 'retryCount' property in config is deprecated; use 'retryLimit' to set maximum retries.
fix
Replace 'retryCount' with 'retryLimit' in the config object.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: axios.poll is not a function
axiosPolling() was not called to extend axios instance.
fix
Call axiosPolling(axios, config) before using axios.poll().
Cannot read properties of undefined (reading 'polling')
Axios defaults are not extended properly or axios instance is not the same as the one passed to axiosPolling.
fix
Ensure the same axios instance is used for both initialization and polling calls.
Module not found: Can't resolve 'axios-polling'
Package not installed or import path incorrect in a CommonJS environment.
fix
Run npm install axios-polling, and use import instead of require if the environment supports ESM.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
axiosrequiredpeer dependency required for polling functionality
Agent activity
11 hits · last 30 days
node
8
Amazon
1
OpenAI (training)
1
Resources
axios-polling — npm install axios-polling · libregistry