Registry / devops / axios-http-client

axios-http-client

JSON →
library1.0.19jsnpmunverified

A wrapper around axios (^0.27.2) and qs (^6.11.0) providing a configurable HTTP client with hooks for request/response interception, custom success code validation, and message display. Current version 1.0.19. It is a thin layer over axios that simplifies configuration and adds Chinese-friendly error handling. Ships TypeScript types.

npm install axios-http-client
INSTALL
IMPORT
SIG · AXIOS-HTTP-CLIENT
A
axios-http-client
devopsjavascriptv1.0.19
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.

HttpClient
import HttpClient from 'http-client'
import { HttpClient } from 'http-client'
Default export only.
HttpClientConfig
import HttpClient, { HttpClientConfig } from 'http-client'
import { HttpClientConfig } from 'http-client'
Config type is a named export alongside default.
HttpClientRequestConfig
import HttpClient, { HttpClientRequestConfig } from 'http-client'
import { HttpClientRequestConfig } from 'http-client'
Request config type is a named export.
type imports
import type { HttpClientConfig, HttpClientRequestConfig } from 'http-client'
import { HttpClientConfig } from 'http-client'
Types can be imported using `import type` in TypeScript for better tree-shaking.

Shows initialization of HttpClient with config including base URL, auth headers, and message hook, then a simple GET request.

import HttpClient, { HttpClientConfig, HttpClientRequestConfig } from 'http-client' const config: HttpClientConfig = { baseURL: 'https://api.example.com', headers: { Authorization: 'Bearer ' + (process.env.KEY ?? 'your-token') }, showMessage: ({ code, message }: { code: number; message: string }) => alert(message) } const http = new HttpClient(config) const options: HttpClientRequestConfig = { url: '/users' } http.request(options).then(res => console.log(res))
Debug
Known issues
gotchaIf `responseAfterHook` is set, the built-in response processing (success code handling) is disabled; you must handle it yourself.
fix
Either omit `responseAfterHook` or manually check the success code inside it.
affects: >=0.0.0
gotchaRequests expecting ArrayBuffer responses must have `responseType: 'arraybuffer'` set. Otherwise the response interceptor may treat it as JSON and cause errors.
fix
Set `responseType: 'arraybuffer'` in the request config.
affects: >=0.0.0
deprecatedPackage name 'http-client' is generic and may conflict with other packages. Consider using the scoped name or a more specific name.
fix
None currently, but be careful in monorepos.
affects: >=0.0.0
gotchaThe `method` defaults to 'GET' if not specified. This can cause unexpected behavior if you forget to set POST for mutations.
fix
Always set `method` explicitly in request config.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: Cannot destructure property 'code' of 'undefined'
Response object is not in expected shape, likely because ArrayBuffer response was not handled correctly.
fix
Set `responseType: 'arraybuffer'` on the request config for binary responses.
Uncaught (in promise) TypeError: axios is not a function
Missing peer dependency 'axios' is not installed.
fix
Run `npm install axios@^0.27.2`.
Module not found: Can't resolve 'qs'
Missing peer dependency 'qs' is not installed.
fix
Run `npm install qs@^6.11.0`.
Upgrade
Version history
1.0.19latest on npm
Audit
Dependencies
axiosrequiredpeer dependency for HTTP requests
qsrequiredpeer dependency for query string parsing
Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
axios-http-client — npm install axios-http-client · libregistry