Catalog npm
PACKAGE EXPLORERView in registry

402.js

npm

A lightweight wrapper around axios that adds 402 Payment Required retry hooks and pluggable paywall handlers.

402apiaxiosmicropaymentspaymentspaywall
Versions collected1
Direct dependencies1From release 1.0.0
Last observed20 Oct, 19:57 UTC

README

Current package documentation

402.js

A tiny axios wrapper that adds HTTP 402 (Payment Required) handling via a pluggable callback.

Install

npm install 402.js
# or
pnpm add 402.js

If you're publishing this yourself, run npm publish inside this folder.

Usage

import { createClient } from "402.js";

const client = createClient({
  maxRetries: 1,
  onPaymentRequired: async ({ config, error, attempt }) => {
    // TODO: trigger your payment flow here (Stripe, Solana, Pump.fun, etc.)
    // Return true to retry the request after payment succeeds.
    console.log("402 received; attempt:", attempt);
    return false;
  }
});

const res = await client.get("https://api.example.com/protected");
console.log(res.data);

API

createClient(options)

  • maxRetries (default 1): number of times to retry after your payment callback returns true.
  • onPaymentRequired(ctx) => Promise<boolean>: called when a response is 402. Return true to retry once payment succeeds.
  • axiosConfig: passed to axios.create().

Returns an object with { axios, get, post, put, patch, delete, request }.

License

MIT

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
1.0.0Registry latest27 Oct 20251

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
yourusername/402.js

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:57 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:f5c115d2ca6d16d5596786c0e0e4844aeea4bb73fd8376c21506321b05b9a080