2.0.2 โ€ข Published 3 months ago

@shivanshusahu/http-helper v2.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
3 months ago

@shivanshusahu/http-helper

A lightweight and customizable HTTP helper utility for Node.js built with TypeScript.
Supports timeouts, automatic retries, custom headers, and HTTP methods โ€” perfect for building scalable and resilient APIs.


๐Ÿš€ Features

  • โœ… Timeout support
  • ๐Ÿ” Retry logic (configurable)
  • ๐Ÿงฐ Custom headers & HTTP methods
  • ๐Ÿ“ฆ ESM support
  • โš™๏ธ Written in TypeScript
  • ๐Ÿงช Easy to test and extend

๐Ÿ“ฆ Installation

npm install @shivanshusahu/http-helper

Usage

import { request } from "@shivanshusahu/http-helper";

const run = async () => {
  try {
    const response = await request(
      "https://jsonplaceholder.typicode.com/posts/1",
      {
        method: "GET",
        headers: {
          Accept: "application/json",
        },
        timeout: 3000,
        retries: 2,
      }
    );

    console.log("Response Body:", response);
  } catch (err) {
    console.error("Error:", err.message);
  }
};

run();

Options

interface RequestOptions {
  method?: string; // GET, POST, PUT, DELETE etc.
  headers?: Record<string, string>; // Custom HTTP headers
  timeout?: number; // Timeout in milliseconds
  retries?: number; // Number of retry attempts
}
2.0.2

3 months ago

2.0.1

3 months ago

2.0.0

3 months ago

1.0.0

3 months ago