@beritani/axios
TypeScript icon, indicating that this package has built-in type declarations

1.4.1 • Public • Published

Axios Helper

Helpful wrappers for axios requests, e.g. rate limiting and max retry attempts.

Rate Limit

Specify how many requests are allowed per second

import axios from "axios";
import { rateLimit } from "@beritani/axios";

rateLimit(axios, 2); // 2 requests per second

axios.get("https://google.com");
axios.get("https://google.com");
axios.get("https://google.com");

Retry on Failed Request

Retry requests, up to the specified limit, when unsuccessful status codes are returned

import axios from "axios";
import { retryFailed } from "@beritani/axios";

const maxAttempts = 3;
const successCodes = [200, 204];

retryFailed(axios, maxAttempts, successCodes);

axios.get("https://google.com");

License

MIT License (MIT). Copyright (c) 2023 Sean N. (https://seann.co.uk)

See LICENSE.

Package Sidebar

Install

npm i @beritani/axios

Weekly Downloads

4

Version

1.4.1

License

MIT

Unpacked Size

6.28 kB

Total Files

7

Last publish

Collaborators

  • beritani