axios-observable-request
v1.0.5
Published
Util to use Axios as RxJs Observer.
Downloads
4
Maintainers
Readme
AxiosObservableRequest
Installation
yarn add axios-observable-request
or
npm install axios-observable-request
Features
- Allow Axios to be used in RxJs.
- Auto-Cancel Axios requests when the Observer is canceled (switchMap, unsubscribe).
Usage
Usage of AxiosObservableRequest with the default Axios config:
import createObservable from "axios-observable-request";
createObservable({
method: "get",
url: "https://google.com"
});
Usage of AxiosObservableRequest with a custom Axios config:
import axios from "axios";
import { createObservableInstance } from "axios-observable-request";
const customAxiosInstance = axios.create({
timeout: 1000,
headers: { "X-Custom-Header": "foobar" }
});
const customCreateObservable = createObservableInstance(customAxiosInstance);
customCreateObservable({
method: "get",
url: "https://google.com"
});
Examples
You can see examples here.
Demo
You can test the demo with react here.