@angelrs/axios-fetch-adapter
v0.3.5
Published
Fetch adapter for axios
Downloads
3
Readme
What
This is a fork of @vespaiach/axios-fetch-adapter with changes specific to a project I'm working on.
Only difference is that it adds support for AbortController.signal
to abort requests while keeping same api to axios' CancelToken
How to use
See test
folder for example of usage
Installation and Usage
You can install the adapter directly from this repository URL or feel free to copy its source code to your project.
npm install axios
npm install @angelrs/axios-fetch-adapter
There are two ways to use it:
- Create a new instance of Axios and pass this adapter in configuration
const instance = axios.create({
baseURL: 'https://some-domain.com/api/',
timeout: 1000,
adapter: fetchAdapter
....
});
- Pass this adapter in each of request
axios.request({
url: '/user',
method: 'get',
adapter: fetchAdapter
...
})
Note
- Since, this adapter relies on fetch API so it won't work in Node environment
Credits
- vespaiach for creating original project