Registry / testing / cyans-axios

cyans-axios

JSON →
library0.1.1jsnpmunverified

A lightweight browser-based HTTP client built with TypeScript, replicating the core functionality of Axios including Promise API, request/response interceptors, data transformation, request cancellation, automatic JSON parsing, and XSS protection. Current version is 0.1.1, experimental with no stable release. Uses XMLHttpRequest under the hood for browser use only (no Node.js support). Ship TypeScript type definitions. Key differentiator: minimal educational clone of Axios intended for learning, not production.

npm install cyans-axios
INSTALL
IMPORT
SIG · CYANS-AXIOS
C
cyans-axios
testingjavascriptv0.1.1
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 (cyanaxios)
import cyanaxios from 'cyans-axios'
const cyanaxios = require('cyans-axios')
Package is ESM-first; Node require() may not work in all environments. In browser with bundler, use ESM import.
AxiosRequestConfig
import type { AxiosRequestConfig } from 'cyans-axios'
import { AxiosRequestConfig } from 'cyans-axios'
TypeScript users: use 'import type' for type-only imports. Runtime import may cause errors.
Method
import { Method } from 'cyans-axios'
TypeScript type for HTTP methods (e.g., 'GET', 'post'). Available as named export.

Demonstrates GET and POST requests using the default export with method, url, params, and data options.

import cyanaxios from 'cyans-axios'; // GET request with params cyanaxios({ method: 'get', url: '/simple/get', params: { a: 1, b: 2 } }).then((response) => { console.log(response.data); }).catch((error) => { console.error(error); }); // POST request with JSON data cyanaxios({ method: 'post', url: '/user/12345', data: { firstName: 'Yee', lastName: 'Huang' } });
Debug
Known issues
breakingBrowser-only: uses XMLHttpRequest, no Node.js compatibility (no http module).
fix
Use a different HTTP client for Node.js (e.g., 'axios' or 'node-fetch').
affects: >=0.0.1
gotchaAll method strings are case-insensitive but only specific values are valid (see Method type). Unknown methods may cause errors.
fix
Ensure method is one of: 'GET'|'get'|'DELETE'|'delete'|'HEAD'|'head'|'OPTIONS'|'options'|'POST'|'post'|'PUT'|'put'|'PATCH'|'patch'.
affects: >=0.0.1
gotchaParams object keys are not automatically encoded; use URLSearchParams for encoding if needed.
fix
Manually encode param values or use a utility like query-string to build params.
affects: >=0.0.1
deprecatedPackage is experimental (v0.1.1) with no stable release; API may change without notice.
fix
Pin to a specific version and test upgrades. Consider using the official 'axios' for stability.
affects: <1.0.0
Errors
Common errors & fixes
TypeError: cyanaxios is not a function
Using require() with default export in CJS context.
fix
Use ESM import: import cyanaxios from 'cyans-axios'; or use .default: const cyanaxios = require('cyans-axios').default;
Uncaught TypeError: Cannot read properties of undefined (reading 'then')
Calling cyanaxios() without returning the Promise chain or missing .catch().
fix
Ensure you handle the returned Promise: cyanaxios({...}).then(...).catch(...);
404 (Not Found)
URL path is relative to current origin; absolute URL not supported?
fix
Use a complete URL string (e.g., '/api/user') relative to the page origin. For absolute URLs, ensure CORS is configured.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
cyans-axios — npm install cyans-axios · libregistry