Introduction
lunex-http is a lightweight, extensible, and strongly-typed HTTP client for interacting with RESTful APIs with support for GET
, POST
, PATCH
, PUT
, DELETE
in JavaScript and TypeScript. Built on the Fetch API, with built-in support for retries, timeouts, and request lifecycle hooks.
The library is fully compatible with CommonJS (CJS), ES module (ESM) and Universal Module Definition (UMD) environments and provides complete TypeScript typings for seamless integration in modern JavaScript and TypeScript projects.
Features
- Supports all standard RESTful HTTP methods:
GET
,POST
,PUT
,PATCH
, andDELETE
- Automatic handling of JSON and plain text responses
- Configurable request timeout management
- Built-in retry mechanism with exponential backoff, customizable per use case
- Support for default headers, including authorization tokens and API keys
- Ability to override headers and append query parameters on a per-request basis
- Request cancellation using AbortController
- Comprehensive error reporting with status code, status text, and response content
- Fully compatible with CommonJS, ES Modules, and UMD environments
- Complete TypeScript typings for type safety and IntelliSense support
Note
This package is the successor to @bishal-shrestha/rest-client
. For previous users of @bishal-shrestha/rest-client
, please migrate to this package for continued support and improvements.