Registry / devops / uniapp-axios-adapter

uniapp-axios-adapter

JSON →
library0.3.2jsnpmunverified

Provides an axios adapter using uni.request for uni-app applications, enabling cross-platform HTTP requests in mini-programs (e.g., WeChat). Current stable version 0.3.2, actively maintained with monthly updates. Key differentiator: seamless integration of axios (v1.x or 0.27.x) into uni-app environments where native XMLHttpRequest is unavailable. Ships TypeScript declarations.

npm install uniapp-axios-adapter
INSTALL
IMPORT
SIG · UNIAPP-AXIOS-ADAPT
U
uniapp-axios-adapter
devopsjavascriptv0.3.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import axios from 'uniapp-axios-adapter';
import { axios } from 'uniapp-axios-adapter';
Default export is a pre-configured axios instance with UniAdapter. Named export 'axios' does not exist.
UniAdapter
import { UniAdapter } from 'uniapp-axios-adapter';
import UniAdapter from 'uniapp-axios-adapter/UniAdapter';
Named export for the raw adapter. Use when creating a custom axios instance.
axios (own instance)
import axios from 'axios'; import { UniAdapter } from 'uniapp-axios-adapter'; const instance = axios.create({ adapter: UniAdapter });
import { UniAdapter } from 'uniapp-axios-adapter'; const axios = require('axios'); const instance = axios.create({ adapter: UniAdapter });
CommonJS require is supported but TypeScript may complain; prefer ESM imports.

Demonstrates using the pre-configured axios instance to make a GET request in uni-app.

import axios from 'uniapp-axios-adapter'; async function getUser() { try { const response = await axios.get('https://api.example.com/user', { params: { id: 1 } }); console.log(response.data); } catch (error) { console.error(error); } } getUser();
Debug
Known issues
deprecatedaxios v1.0+ may have breaking changes not fully compatible with this adapter; recommended version is 0.27.2.
fix
Install axios@0.27.2 as a direct dependency and use import { UniAdapter } from 'uniapp-axios-adapter' with custom instance.
affects: >=1.0.0
gotchaThe adapter only supports uni.request; it does not handle uni.downloadFile or uni.uploadFile (planned in TODO). Uploads must use alternative methods.
fix
Use uni.uploadFile directly for file uploads, or implement a custom adapter.
affects: >=0.0.1
gotchaWhen using the default export, the adapter is already set; calling axios.create() overrides it unless you pass the adapter option again.
fix
To customize configuration while keeping the adapter, use: const instance = axios.create({ baseURL: '...', adapter: UniAdapter });
affects: *
Errors
Common errors & fixes
Cannot find module 'uniapp-axios-adapter' or its corresponding type declarations.
Package not installed or TypeScript cannot resolve types.
fix
Run pnpm/npm install uniapp-axios-adapter. Ensure tsconfig includes node module resolution.
Uncaught TypeError: axios is not a function
Incorrect import: using import { axios } instead of default import.
fix
Use import axios from 'uniapp-axios-adapter';
Network request failed: adapter is not a function
Using axios without the UniAdapter in uni-app environment (e.g., mini-program).
fix
Either import default axios from 'uniapp-axios-adapter' or set adapter: UniAdapter manually.
Upgrade
Version history
0.3.2latest on npm
Audit
Dependencies
axiosrequiredPeer dependency for HTTP request core; adapter requires axios instance to function.
Agent activity
6 hits · last 30 days
node
6
Resources
uniapp-axios-adapter — npm install uniapp-axios-adapter · libregistry