Registry / communication / axios-observable

axios-observable

JSON →
library2.1.0jsnpmunverified

axios-observable wraps axios to return RxJS Observables instead of Promises, enabling operators like retry, debounce, and switchMap for HTTP requests. Current stable version is 2.1.0, with peer dependencies axios ^1.2.1 and rxjs ^7.0.0. It ships TypeScript types and supports both browser and Node.js. Compared to alternatives like rxjs/ajax, it provides a familiar axios API for migration. Release cadence is low; maintained by community. Key differentiator: drop-in replacement for axios with Observable support, but does not support calling Axios as a function directly.

npm install axios-observable
INSTALL
IMPORT
SIG · AXIOS-OBSERVABLE
A
axios-observable
communicationjavascriptv2.1.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.

Axios
import { Axios } from 'axios-observable'
const Axios = require('axios-observable')
Named export (not default). CommonJS users must use .Axios property.
default import
import { Axios } from 'axios-observable'
import Axios from 'axios-observable'
No default export; must use named import.
Axios instance
const instance = Axios.create({baseURL: '...'})
Axios({method: 'post'})
Direct call as function is not supported; use Axios.request(config) or alias methods.

Demonstrates GET and POST requests with RxJS observable, including retry operator and handling responses.

import { Axios } from 'axios-observable'; import { retry } from 'rxjs/operators'; import { of } from 'rxjs'; // Make a GET request with retry Axios.get('https://jsonplaceholder.typicode.com/posts/1') .pipe( retry(3) ) .subscribe({ next: response => console.log(response.data), error: err => console.error('Request failed:', err) }); // POST request Axios.post('https://jsonplaceholder.typicode.com/posts', { title: 'foo', body: 'bar', userId: 1 }).subscribe({ next: response => console.log('Created:', response.data), error: err => console.error(err) });
Debug
Known issues
breakingCannot call Axios as a function; must use Axios.request(config) or alias methods.
fix
Replace direct invocation with Axios.request(config) or a method like Axios.get(url).
affects: >=1.0.0
gotchaNamed export only: use `import { Axios } from 'axios-observable'`, not default import.
fix
Use named import syntax.
affects: >=1.0.0
gotchaReturns Observable, not Promise; cannot use .then() or await directly.
fix
Subscribe to the Observable or convert to Promise via .toPromise() (deprecated in RxJS 7).
affects: >=1.0.0
deprecated.toPromise() is deprecated in RxJS 7; use lastValueFrom or firstValueFrom instead.
fix
Use lastValueFrom(axiosObservable$) or firstValueFrom(axiosObservable$).
affects: >=2.0.0
gotchaCancellation through unsubscribe does not abort underlying XMLHttpRequest in some old versions.
fix
Upgrade to >=1.1.0 for proper cancellation via unsubscribe.
affects: <1.1.0
Errors
Common errors & fixes
TypeError: Axios is not a function
Attempted to call Axios as a function, which is not supported.
fix
Use Axios.request(config) or alias methods like Axios.get(url).
Module '"axios-observable"' has no default export
Default import syntax used but package only exports named export.
fix
Use `import { Axios } from 'axios-observable'`.
Observable.subscribe is not a function (or similar)
Attempted to use .then() on the returned Observable.
fix
Use .subscribe() or convert to Promise with lastValueFrom().
Upgrade
Version history
2.1.0latest on npm
Audit
Dependencies
axiosrequiredpeer dependency for HTTP requests; version >=1.2.1
rxjsrequiredpeer dependency for Observable implementation; version >=7.0.0
Agent activity
48 hits · last 30 days
node
42
OpenAI (training)
1
Resources
axios-observable — npm install axios-observable · libregistry