btch-http is a lightweight and type-safe HTTP client for Node.js, built directly on the Node.js `https` module, ensuring zero external dependencies. The current stable version is 2.0.3, with recent minor updates following a major version 2.0.0 release. It differentiates itself by offering full TypeScript support out-of-the-box, smart error handling that consolidates network, timeout, and HTTP status code (>=300) errors into a custom `HttpError` class, and comprehensive timeout support. It provides both a quick one-liner `HttpGet` function for simple GET requests with URL encoding and a full-featured `HttpClient` class for more complex interactions involving configurable base URLs, versions, default headers, and POST requests with JSON bodies or custom headers. It requires Node.js >=20.18.1.
npm install btch-httpVerified import paths — ran on the pinned version, not inferred.
Demonstrates a quick, one-liner GET request using `HttpGet` to retrieve data from a TikTok video downloader API.
Migrate your project to use ES modules (`import`/`export`) or use dynamic `import()` for `btch-http`.
Upgrade your Node.js environment to version 20.18.1 or newer.
Be aware of this automatic URL encoding when using `HttpGet`. For more explicit control over query parameters, consider using the `HttpClient` class and its `get` method.
Always wrap your `btch-http` calls in `try...catch` blocks and use `instanceof HttpError` to specifically handle API-related errors, allowing you to inspect `error.status`, `error.message`, and `error.response`.
Use ES module import syntax: `import { SymbolName } from 'btch-http';`Ensure you are using `import { HttpClient } from 'btch-http';` and your project is configured for ES modules, with a compatible Node.js version.Verify your internet connection, ensure the target `baseUrl` is correct and accessible, and check firewall settings. The `HttpError` will contain details about the underlying network issue.
No dependency data recorded yet.