This package provides an Axios adapter for any custom fetch function that implements the standard fetch interface for making HTTP requests.
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!
tauri-plugin-http = { version = "2.0.0-beta", features = ["rustls-tls","unsafe-headers"] }
- this is still in beta stage and improving
- cookie features are in progress (@tauri)
npm install --save fetchify-axios
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.
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.
MIT