Socket
Socket
Sign inDemoInstall

@vespaiach/axios-fetch-adapter

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vespaiach/axios-fetch-adapter

Fetch adapter for axios


Version published
Weekly downloads
28K
increased by18.46%
Maintainers
1
Weekly downloads
 
Created
Source

Why

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.

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 @vespaiach/axios-fetch-adapter

There are two ways to use it:

  1. 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
  ....
});
  1. Pass this adapter in each of request
axios.request({
  url: '/user',
  method: 'get',
  adapter: fetchAdapter
  ...
})
  1. Use with FormData
axios.request({
  url: '/user',
  method: 'post',
  adapter: fetchAdapter
  data: new FormData(formId)
  ...
})

Note

  • Since, this adapter relies on fetch API so it won't work in Node environment

Keywords

FAQs

Package last updated on 30 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc