Registry / devops / piral-axios

piral-axios

JSON →
library1.11.0jsnpmunverified

Plugin for integrating axios HTTP client into Piral microfrontend applications. Current stable version: 1.11.0. Released as part of the Piral ecosystem, with regular updates aligned to Piral releases. Key differentiator: provides a pre-configured axios instance on the pilet API that is automatically wired with authentication and base URL settings, simplifying HTTP requests in pilets. Alternatives include sharing axios as a shared dependency.

npm install piral-axios
INSTALL
IMPORT
SIG · PIRAL-AXIOS
P
piral-axios
devopsjavascriptv1.11.0
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.

createAxiosApi
import { createAxiosApi } from 'piral-axios'
const createAxiosApi = require('piral-axios')
ESM-only; this is the main entry point for Piral instance developers
AxiosInstance
import type { AxiosInstance } from 'piral-axios'
Type import for TypeScript users, available in v1.x
Axios
import { PiletApi } from '<name-of-piral-instance>'; // axios is available on piral.axios
import { axios } from 'piral-axios'
The axios object is not directly exported from piral-axios; it's exposed as piral.axios via the pilet API

Shows how to integrate piral-axios into a Piral instance and use the axios object in a pilet with a relative URL.

// Piral instance setup import { createInstance } from 'piral-core'; import { createAxiosApi } from 'piral-axios'; const instance = createInstance({ plugins: [createAxiosApi({ baseURL: process.env.API_BASE_URL ?? 'http://localhost:3000/api', })], // ... other settings }); // In a pilet import { PiletApi } from '<piral-instance>'; export function setup(piral: PiletApi) { piral.axios.get('/users').then(response => { console.log(response.data); }); }
Debug
Known issues
breakingBefore v1.5.0, createAxiosApi accepted options differently; check the migration guide if upgrading from older versions.
fix
Update to latest version and adjust options object if needed.
affects: <1.5.0
gotchaThe axios instance is shared across all pilets; modifying defaults (e.g., setting default headers) affects all pilets.
fix
Use per-request configuration instead of mutating the shared instance.
affects: >=1.0.0
deprecatedUsing the axios object as a global variable is deprecated; always access it via piral.axios.
fix
Use the pilet API parameter to obtain the axios instance.
affects: >=1.8.0
gotchaAuthentication tokens are automatically inserted only on requests to the base URL; requests to other URLs may not include tokens.
fix
Ensure all API requests go to the base URL or manually attach tokens.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'piral-axios' or its corresponding type declarations.
Missing peer dependency piral-core or incorrect module resolution.
fix
Install piral-core as a dependency: npm install piral-core
'createAxiosApi' is not exported from 'piral-axios'.
Using CommonJS require on an ESM-only package.
fix
Use import instead of require, or ensure ESM is enabled.
TypeError: Cannot read properties of undefined (reading 'get')
Trying to use piral.axios without piral instance being fully initialized or without the plugin being registered.
fix
Ensure createAxiosApi is included in the plugins array when creating the Piral instance.
Upgrade
Version history
1.11.0latest on npm
Audit
Dependencies
piral-corerequiredPeer dependency - required to provide the pilet API extension
Agent activity
10 hits · last 30 days
node
8
Amazon
1
Resources
piral-axios — npm install piral-axios · libregistry