
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
Pluggable & Promise based HTTP client for the browser and node.js

![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|---|---|---|---|---|---|
| Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |
$ npm install net4j
$ yarn add net4j
Performing a GET request
import Net from 'net4j';
const net = new Net();
// Type merge,so that /api/v2/goods will be typed
declare module 'net4j' {
interface IGetRoute {
'/api/v2/goods': {
request: {
id: number
}
response: {
data: {
GoodsInfo
}
}
},
}
}
// `GET` request
// result will be typed with {data: {GoodsInfo}}
const result = await net.get('/api/v2/goods');
import Net from 'net4j';
const net = new Net();
// Type merge,so that /api/v2/goods/:id will be typed
declare module 'net4j' {
interface IGetRoute {
'/api/v2/goods/:id': {
response: {
data: {
GoodsInfo
}
}
},
}
}
// `GET` request
// result will be typed with {data: {GoodsInfo}}
const result = await net.get('/api/v2/goods/:id', {restful: {id: 123}});
import Net from 'net4j';
import { message, Modal } from 'antd';
import NetLog from 'net4j-log-plugin';
import NetSuccess, { SuccessConfig } from 'net4j-success-plugin';
import NetLoading, { LoadingConfig } from 'net4j-loading-plugin';
import NetException, { ExceptionConfig } from 'net4j-exception-plugin';
declare module 'net4j' {
// Merge plugin config to net4j config,then you can use it in every requst in net4j
interface IConfig extends SuccessConfig, LoadingConfig, ExceptionConfig {};
// Type merge,so that /api/v2/goods will be typed
interface IGetRoute {
'/api/v2/goods': {
request: {
id: number
}
response: {
data: {
GoodsInfo
}
}
},
}
}
// Exception code to message
// Exception code comes from http status,response result.code,promise reject error.code
const codeMsgMap = {
404: 'page not found',
403: function() {
// In this time, tipsComponent will not show.
redirect('/login');
},
5400: 'Name repeat'
}
const net = new Net(plugins: [
// Inject own log,so the exception and other operations will be reported
new NetLog({
log: {
info: myLogger.info,
error: myLogger.error,
},
}),
// When request is pending, message loading will display and close when request finish
new NetLoading({
loading: message.loading,
}),
// When request completed successfully, message.success will display
new NetSuccess({
tipsComponent: message.success,
}),
// When request get exception,error modal will display and error will be auto reported
new NetException({
tipsComponent: Modal.error,
codeMsgMap,
}),
]);
// `GET` request
// result will be typed with {data: {GoodsInfo}}
const result = await net.get('/api/v2/goods', {params: {id: 123}});
export interface Plugin {
beforeRequest?(e?: Error, config?: AxiosRequestConfig, lib?: Lib): IConfig | Promise<Config>;
// Inject libs to whole request, so other plugins use these libs
applyLib?(lib: { [key: string]: any}): { [key: string]: any};
afterRequest?<T = any>(e?: Error, response?: T, lib?: Lib): T | Promise<AxiosResponse<Error>>;
}
FAQs
Pluggable & Promise based HTTP client for the browser and node.js
The npm package net4j receives a total of 5 weekly downloads. As such, net4j popularity was classified as not popular.
We found that net4j demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.