Registry / testing / moleculer-axios

moleculer-axios

JSON →
library0.1.3jsnpmunverified

moleculer-axios is an Axios-based HTTP client for Moleculer microservice services (v0.1.3). It enables services to make outgoing HTTP requests via a mixin that attaches an `axios` instance to the service context. The package depends on `moleculer` as a peer dependency and requires Node.js >= 8.x. Key differentiator: integrates Axios into the Moleculer lifecycle and service schema, providing automatic error handling and context propagation. Last released in 2019 with no recent updates, indicating limited maintenance.

npm install moleculer-axios
INSTALL
IMPORT
SIG · MOLECULER-AXIOS
M
moleculer-axios
testingjavascriptv0.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.

default
import MoleculerAxios from 'moleculer-axios';
const MoleculerAxios = require('moleculer-axios');
Package provides a default export. Use ESM import for modern Node.
MoleculerAxios
import MoleculerAxios from 'moleculer-axios';
import { MoleculerAxios } from 'moleculer-axios';
Avoid named import; the package does not export a named `MoleculerAxios`.
AxiosService
const { AxiosService } = require('moleculer-axios');
const AxiosService = require('moleculer-axios').AxiosService;
AxiosService is a named export from the package, but also available as default. For clarity, use destructured require.

Shows how to create a Moleculer service with the axios mixin and make an HTTP GET request via ctx.axios.

const { ServiceBroker } = require('moleculer'); const MoleculerAxios = require('moleculer-axios'); const broker = new ServiceBroker(); broker.createService({ name: 'greeter', mixins: [MoleculerAxios], actions: { async callHttp(ctx) { const res = await ctx.axios.get('https://api.example.com/data'); return res.data; } } }); broker.start() .then(() => broker.call('greeter.callHttp')) .then(console.log) .catch(console.error);
Debug
Known issues
deprecatedPackage not updated since 2019; may not work with latest Moleculer versions.
fix
Consider alternative such as manually using axios in service actions, or audit compatibility.
affects: >=0.14.0
breakingRequires Node.js >= 8.x; Node 8 is end-of-life. May fail on newer Node versions due to internal API changes.
fix
Upgrade Node.js or use a transpiler. Check Node.js compatibility.
affects: >=0.1.0
gotchaDefault export is an object, not a mixin function. Must be used as a mixin in service schema.
fix
Use `mixins: [MoleculerAxios]` (not `mixins: [MoleculerAxios.default]`).
affects: >=0.1.0
gotchaThe axios instance is attached to `ctx.axios` inside actions only; not available outside action context.
fix
Ensure you access `ctx.axios` within an action handler, not in lifecycle hooks or service methods.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: Cannot read property 'get' of undefined
Accessing ctx.axios outside of an action context (e.g., in created hook).
fix
Move HTTP call to an action method.
Error: Cannot find module 'moleculer-axios'
Package not installed or import path incorrect.
fix
Run `npm install moleculer-axios` and ensure no typo in import.
TypeError: ServiceBroker is not a constructor
Using ES module import with require style or outdated Node.
fix
Use `const { ServiceBroker } = require('moleculer');` or ensure Node >= 8.
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies
moleculerrequiredPeer dependency required for service runner and context
Agent activity
4 hits · last 30 days
node
4
Resources
moleculer-axios — npm install moleculer-axios · libregistry