New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

axios-ky-adapter

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-ky-adapter

An axios adapter for the ky http client

  • 1.0.7
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Axios Ky Adapter

An Axios adapter for Ky, a tiny and elegant HTTP client based on the browser Fetch API

npm version npm downloads dependencies

This is an adapter for those who would like to use the Fetch API in Axios.
I used ky because it simplifies a lot of things, but behind the scenes all requests are done with fetch.

So if you have an old project that still uses Axios / XHR, and want to switch to the newer standard, then just throw this adapter in and you're good to go!
I've implemented most of the features available in the built-in Axios XHR Adapter, so it should work as before.

Installation

Using npm:

$ npm install axios-ky-adapter

Usage

const axios = require('axios');
const kyAdapter = require('axios-ky-adapter');

axios.get('https://example.com', {
     adapter: kyAdapter
}).then(function (response) {
     // handle success
     console.log(response);
}).catch(function (error) {
     // handle error
     console.log(error);
})

You can even pass some options directly to ky (which will be passed on to fetch), if you want:

const axios = require('axios');
const kyAdapter = require('axios-ky-adapter');
const fetch = require('isomorphic-unfetch');

kyAdapter.kyOptions = {
    mode: 'cors', // set CORS mode (fetch option)
    fetch, // pass custom fetch implementation (ky option)
};

axios.get('https://example.com', {
    adapter: kyAdapter
}).then(function (response) {
     // handle success
     console.log(response);
}).catch(function (error) {
     // handle error
     console.log(error);
})

Browser / Node.js support

This adapter uses ky-universal so it should work in the browser and in Node.js.
For more information check the ky and ky-universal docs!

  • axios - Promise based HTTP client for the browser and node.js
  • ky - Tiny and elegant HTTP client based on the browser Fetch API
  • ky-universal - Use Ky in both Node.js and browsers

License

Keywords

FAQs

Package last updated on 21 Jul 2020

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