Skip to content

DylanMerigaud/axios-observable-request

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AxiosObservableRequest

npm GitHub last commit PRs Welcome

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.