Registry / devops / axios-taro-adapter

axios-taro-adapter

JSON →
library0.0.3jsnpmunverified

An axios adapter that allows using axios with Taro's request API in Taro miniapp projects. Version 0.0.3, released as an early-stage package with no regular release cadence. It enables developers to use the familiar axios interface and interceptors in Taro apps, while Taro handles the underlying multi-platform networking. Key differentiator: allows code reuse between web and miniapp environments by using axios instead of Taro.request directly. Currently only provides the TaroAdapter export.

npm install axios-taro-adapter
INSTALL
IMPORT
SIG · AXIOS-TARO-ADAPTER
A
axios-taro-adapter
devopsjavascriptv0.0.3
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.

TaroAdapter
import { TaroAdapter } from 'axios-taro-adapter'
import TaroAdapter from 'axios-taro-adapter'
Named export only; default import is not available.

Shows how to create an axios instance with TaroAdapter and set up request/response interceptors.

import { TaroAdapter } from 'axios-taro-adapter'; import axios from 'axios'; const instance = axios.create({ baseURL: 'https://api.xxxx.com/', timeout: 10000, adapter: TaroAdapter, }); instance.interceptors.request.use(config => { // modify config if needed return config; }, error => Promise.reject(error)); instance.interceptors.response.use(response => { if (response.data.code !== 0) { return Promise.reject(response.data); } return response.data; }, error => Promise.reject(error.message));
Debug
Known issues
gotchaThis package is in early development (v0.0.3); API may change without major version bump.
fix
Pin exact version and test upgrades carefully.
affects: <1.0.0
gotchaMust install both axios and this adapter as dependencies; not declared as peer dependencies in package.json.
fix
Run `npm install axios axios-taro-adapter`.
affects: >=0.0.0
gotchaTaroAdapter is a named export; trying default import will result in undefined.
fix
Use `import { TaroAdapter } from 'axios-taro-adapter'`.
affects: >=0.0.0
gotchaAdapter only works in Taro miniapp environments; not suitable for browser or Node.js.
fix
Ensure code runs in Taro context before using adapter.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'request')
Taro.request not available (not running in a Taro miniapp environment)
fix
Ensure your code runs inside a Taro app, e.g., in a page or component.
Module not found: Can't resolve 'axios-taro-adapter'
Package not installed or import path incorrect
fix
Run `npm install axios-taro-adapter --save` and verify import statement.
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies
axiosrequiredpeer dependency; the adapter is designed to work with axios instances
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
axios-taro-adapter — npm install axios-taro-adapter · libregistry