$ npm install @taquito/axios-fetch-adapter
I'm going to adopt PWA to my web applications and those web apps are heavily using Axios with the default XMLHTTPRequest adapter. Hence, I have to switch to Fetch adapter; However, Axios doesn't have an adapter for fetch API for now. So I write one to use while waiting for an offical one from Axios.
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 @vespaiach/axios-fetch-adapter
There are two ways to use it:
const instance = axios.create({
baseURL: 'https://some-domain.com/api/',
timeout: 1000,
adapter: fetchAdapter
....
});
axios.request({
url: '/user',
method: 'get',
adapter: fetchAdapter
...
})
axios.request({
url: '/user',
method: 'post',
adapter: fetchAdapter
data: new FormData(formId)
...
})
© 2010 - cnpmjs.org x YWFE | Home | YWFE