Registry / testing / rxjs-axios

rxjs-axios

JSON →
library1.7.0jsnpmunverified

An RxJS-based wrapper around Axios that returns observables for HTTP requests, supporting cancellation, retries, and transformation. As of v1.7.0 (stable, maintained), it requires Node >=18, axios >=1.0.0, and rxjs >=5.5.12. It provides a complete Axios client interface but with reactive patterns. Key differentiator: seamless integration of Axios features with RxJS observables, enabling composition with other reactive streams. No direct support for browser environments as it relies on Node's http module.

npm install rxjs-axios
INSTALL
IMPORT
SIG · RXJS-AXIOS
R
rxjs-axios
testingjavascriptv1.7.0
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.

AxiosObservable
import { AxiosObservable } from 'rxjs-axios'
const { AxiosObservable } = require('rxjs-axios')
Package is ESM-only since v1.0; default export is the Axios class.
Axios
import { Axios } from 'rxjs-axios'
import Axios from 'rxjs-axios'
Named export, not default. The class is exported as 'Axios'.
create
import { create } from 'rxjs-axios'
import Axios, { create } from 'rxjs-axios'
The factory function 'create' is a named export, but the default export is undefined. Use named import.

Creates an Axios-like client returning Observables instead of promises. Demonstrates GET request, response transformation, and cancellation via unsubscribe.

import { create } from 'rxjs-axios'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; const client = create({ baseURL: 'https://api.example.com' }); const request$ = client.get('/data', { params: { id: 1 } }); // request$ is Observable<AxiosResponse> request$.pipe( map(response => response.data) ).subscribe({ next: data => console.log('Received:', data), error: err => console.error('Error:', err) }); // Cancellation example const subscription = request$.subscribe(); setTimeout(() => subscription.unsubscribe(), 5000);
Debug
Known issues
breakingv1.0.0 removed support for CommonJS require() - all imports must use ESM syntax.
fix
Use import { ... } from 'rxjs-axios' instead of require('rxjs-axios').
affects: >=1.0.0
gotchaThe Axios class is a named export, not default. Attempting import Axios from 'rxjs-axios' yields undefined at runtime.
fix
Use import { Axios } from 'rxjs-axios'.
affects: >=1.0.0
deprecatedThe legacy AxiosObservable type alias has been deprecated in favor of AxiosResponse<...>.
fix
Use AxiosResponse directly from the package or axios types.
affects: >=1.5.0
breakingv1.7.0 dropped support for Node <18 due to ESM constraints.
fix
Upgrade Node.js to version 18 or higher.
affects: >=1.7.0
gotchaCancellation is only possible by unsubscribing from the Observable. Using axios CancelToken does not work.
fix
Use RxJS Subscription.unsubscribe() to cancel requests.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: axios_1.default is not a constructor
Using default import or require() when package is ESM-only and exports Axios as named export.
fix
Change import to: import { Axios } from 'rxjs-axios'; OR use dynamic import: const { Axios } = await import('rxjs-axios');
Cannot find module 'rxjs-axios' or its corresponding type declarations.
Missing type definitions due to misconfigured tsconfig.json or using an older version without types.
fix
Ensure tsconfig.json has 'moduleResolution': 'node' or 'node16'. For TypeScript <4.7, add 'paths': { 'rxjs-axios': ['./node_modules/rxjs-axios/dist/index.d.ts'] }
rxjs_1.Observable is not a function
Using a bundler that does not support RxJS pipeable operators, or mixing import styles.
fix
Import Observable from 'rxjs' and operators from 'rxjs/operators'. Avoid import { Observable } from 'rxjs/Observable'.
Upgrade
Version history
1.7.0latest on npm
Audit
Dependencies
axiosrequiredPeer dependency: provides the underlying HTTP client
rxjsrequiredPeer dependency: provides Observables and operators
Agent activity
7 hits · last 30 days
node
6
Resources
rxjs-axios — npm install rxjs-axios · libregistry