Registry / testing / complex-request-axios

complex-request-axios

JSON →
library1.1.3jsnpmunverified

An official axios adapter for the complex-request library, providing a layered architecture for HTTP requests with token management, login/refresh automation, and response parsing. Current stable version is 1.1.3. It wraps complex-request's core features using axios as the underlying HTTP client, allowing full access to axios's ecosystem (interceptors, cancellation, progress events). Requires both complex-request and axios as peer dependencies. The API mirrors complex-request's BaseRequest but uses AxiosRequest instead, with optional axios-specific configuration at initialization and per-request.

npm install complex-request-axios
INSTALL
IMPORT
SIG · COMPLEX-REQUEST-AX
C
complex-request-axios
testingjavascriptv1.1.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.

AxiosRequest
✓ import { AxiosRequest } from 'complex-request-axios'
✗ import AxiosRequest from 'complex-request-axios'
Named export, not default. The package exports only AxiosRequest class.
Rule
✓ import { Rule } from 'complex-request'
✗ import { Rule } from 'complex-request-axios'
Rule is from complex-request package, not the adapter.
AxiosResponse, AxiosRequestConfig
✓ import type { AxiosResponse, AxiosRequestConfig } from 'axios'
✗ import { AxiosResponse } from 'complex-request-axios'
Axios types are from the axios package itself, used for type parameters.

Shows creating a Rule with token and parse logic, instantiating AxiosRequest with baseUrl and rule, and making a GET request with axios-specific config.

import { AxiosRequest } from 'complex-request-axios'; import { Rule } from 'complex-request'; import type { AxiosResponse, AxiosRequestConfig } from 'axios'; const myRule = new Rule<AxiosResponse>({ prop: 'api', token: { data: { accessToken: { location: 'header', require: true } } }, parse: (response) => { const { data } = response; if (data.code === 200) { return { status: 'success', data: data.data }; } else if (data.code === 401) { return { status: 'login', data: null, msg: '请先登录' }; } else { return { status: 'fail', data: null, msg: data.message }; } }, login: () => { /* login logic */ } }); const myRequest = new AxiosRequest({ baseUrl: 'https://api.example.com', rule: myRule, axios: { timeout: 5000 } }); myRequest.get({ url: '/user/profile', local: { onUploadProgress: (e) => {} } as AxiosRequestConfig }) .then(response => console.log('User:', response.data)) .catch(error => console.error('Error:', error));
Debug
Known issues
gotchaAxiosRequestConfig for per-request options must be cast or typed explicitly as AxiosRequestConfig, as the local property expects a generic object.
fix
Use 'as AxiosRequestConfig' or define local with type AxiosRequestConfig.
affects: >=1.0.0
gotchaThe parse function returns an object with 'status' field; ensure your login logic returns a similar shaped object or uses the built-in mechanisms.
fix
Check complex-request documentation for expected parse return shape.
affects: >=1.0.0
deprecatedIf using complex-request versions <1.0.0, the API may differ. This adapter requires complex-request ^1.0.0.
fix
Upgrade complex-request to >=1.0.0.
affects: <1.0.0
gotchaThe token location 'header' is case-sensitive; all token config values must match exactly as documented.
fix
Use lowercase values for location (e.g., 'header', 'body').
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'complex-request-axios'
Package not installed or missing from node_modules.
fix
npm install complex-request-axios axios complex-request
Attempted import error: 'AxiosRequest' is not exported from 'complex-request-axios'
Using default import instead of named import.
fix
Use import { AxiosRequest } from 'complex-request-axios'
TypeError: Rule is not a constructor
Rule imported from wrong package or not imported at all.
fix
import { Rule } from 'complex-request'
Property 'get' does not exist on type 'AxiosRequest<...>'
Missing complex-request dependency or incorrect version.
fix
Ensure complex-request is installed and at version ^1.0.0
Upgrade
Version history
1.1.3latest on npm
Audit
Dependencies
complex-requestrequiredCore library providing the request framework, rule engine, and token management
axiosrequiredUnderlying HTTP client used for actual network requests
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
complex-request-axios — npm install complex-request-axios · libregistry