Tinyreq is a minimalist JavaScript library designed for making HTTP and HTTPS requests, aiming for simplicity and a small footprint. Currently at version 3.4.3, it offers both traditional callback-based and modern Promise-based APIs for handling responses. Its release cadence is generally conservative, with updates focusing on maintenance tasks such as documentation improvements, minor dependency upgrades (e.g., `follow-redirects`), and occasional bug fixes (e.g., addressing Promise handling in 3.2.5). A key differentiating factor is its commitment to being a "tiny" utility, providing core request functionality without the extensive feature sets found in larger HTTP clients, making it suitable for environments where bundle size and minimal dependencies are crucial.
npm install tinyreqVerified import paths — ran on the pinned version, not inferred.
Demonstrates making basic GET requests using both callback and Promise patterns, and a POST request with data to an external endpoint.
Upgrade to `tinyreq` version 3.2.5 or higher to ensure correct Promise behavior for accessing response bodies.
Use `import tinyreq from 'tinyreq';` for ESM, and ensure your build setup correctly handles CommonJS modules. Avoid `import { tinyreq } from 'tinyreq';`.Always check both `err` and `body` in callbacks, and utilize `.catch()` for Promise-based requests to handle potential network or server errors gracefully.
For CommonJS, use `const tinyreq = require('tinyreq');`. For ESM, use `import tinyreq from 'tinyreq';`.Verify the URL for typos and ensure network connectivity or correct DNS configuration. Try pinging the domain from your environment.
Ensure you are using `tinyreq` version 3.2.5 or newer. Also, verify that `tinyreq` is called with a string URL or an object with a `url` property, which should return a Promise when no callback is provided.