fetchify-axios
v1.0.6
Published
Fetchify Axios is a fetch adapter for Axios that takes any function that implements the standard fetchAPI interface!
Downloads
4
Maintainers
Readme
Fetchify-Axios
This package provides an Axios adapter for any custom fetch function that implements the standard fetch interface for making HTTP requests.
Motive
This adapter was primarily build to work with http-plugin of tauri v2 via axios but also capable to handle any type of function that implements fetch interface!
Don't forget to enable this feature flags
tauri-plugin-http = { version = "2.0.0-beta", features = ["rustls-tls","unsafe-headers"] }
Limitations
- this is still in beta stage and improving
- cookie features are in progress (@tauri)
Installation
npm install --save fetchify-axios
Usage
import createFetchAdapter, { type fetch } from "fetchify-axios";
import axios from "axios";
const myFetch: fetch = async (input, init) => {
// create your custom fetch function or,
//use any fetch plugin that implements the fetch interface
};
// Create a new instance of axios with a custom adapter
const instance = axios.create({
adapter: createFetchAdapter(myFetch),
});
// Use axios instance to make requests
instance.get("/url").then((response) => {
console.log(response.data);
});
In this example, myFetch
is a custom fetch function. It can be any function that has the same signature as the Fetch API's fetch
function.
API
createFetchAdapter(fetch)
Creates a new Axios adapter that uses the given fetch
function to make HTTP requests.
fetch
: A function that has the same signature as the Fetch API'sfetch
function.
Returns an Axios adapter.
License
MIT