tauri-http-axios-adapter
v1.0.3
Published
An axios adapter for the Tauri HTTP plugin, enabling seamless HTTP requests in Tauri applications while maintaining compatibility with Axios.
Downloads
283
Readme
Axios Adapter for Tauri HTTP Plugin
An axios adapter for the Tauri HTTP plugin, enabling seamless HTTP requests in Tauri applications while maintaining compatibility with Axios.
Installation
# npm
npm install your-package-name
# pnpm
pnpm add your-package-name
# yarn
yarn add your-package-name
Usage
Import and configure Axios to use the Tauri HTTP adapter:
import axios from 'axios'
import axiosTauriAdapter from 'tauri-http-axios-adapter'
// Set Axios to use the Tauri adapter
const api = axios.create({
adapter: axiosTauriAdapter,
})
Ensure that the Tauri API permissions for HTTP are enabled:
{
"permissions": [
{
"identifier": "http:default",
"allow": [{ "url": "https://*.tauri.app" }],
"deny": [{ "url": "https://private.tauri.app" }]
}
]
}
Configuration
You can configure Axios as you normally would. This adapter supports all the usual Axios options, except that requests are processed through Tauri's HTTP module.
For example:
const api = axios.create({
adapter: axiosTauriAdapter,
baseURL: 'https://your-api-endpoint.com',
timeout: 5000,
headers: {
Authorization: 'Bearer your-token',
'Content-Type': 'application/json',
},
})