Registry / http-networking / tiny-json-http

tiny-json-http

JSON →
library7.5.1jsnpmunverified

tiny-json-http is a minimalist HTTP client designed for making GET, POST, PUT, PATCH, and DELETE requests, primarily handling JSON payloads. Currently stable at version 7.5.1, it emphasizes a small footprint with zero external dependencies, making it particularly well-suited for constrained environments like AWS Lambda functions. The library offers a dual API, supporting both Node.js-style errback callbacks and Promises, which enables modern `async/await` usage. Its core differentiators include automatically assuming buffered JSON responses, a system-symmetric API, and a focus on simplicity over extensive configuration, making it a straightforward choice for basic HTTP interactions without the overhead of more feature-rich clients. The project maintains a steady release cadence for bug fixes and minor improvements, with major versions introducing breaking changes as needed.

http-networking
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tiny-json-http is primarily a CommonJS module. Direct ESM `import` statements may require bundler configuration or specific `import` paths (e.g., `import tiny from 'tiny-json-http/index.js'`) for full compatibility, though bundlers often handle this seamlessly.

const tiny = require('tiny-json-http')

Individual methods like `get`, `post`, etc., are available directly on the module export object.

const { get } = require('tiny-json-http')

When using ESM `import`, ensure your environment or bundler correctly resolves CJS named exports for these methods.

const { post } = require('tiny-json-http')

Demonstrates making a GET request to an external API using async/await syntax and robust error handling.

const tiny = require('tiny-json-http'); const url = 'https://jsonplaceholder.typicode.com/posts/1'; (async function _iife() { try { const result = await tiny.get({ url }); console.log('Successfully fetched data:'); console.log('Headers:', result.headers); console.log('Body:', result.body); } catch (err) { console.error('Error fetching data:', err.message); if (err.statusCode) { console.error('Status Code:', err.statusCode); console.error('Error Body:', err.body); // Server error body if available } } })();
Debug
Known footguns
gotchatiny-json-http automatically attempts to parse responses as JSON. If the server returns a non-JSON body (e.g., HTML error pages, plain text, or empty responses), this will result in a JSON parsing error.
gotchaThe `del` (DELETE) method accepts a `data` object, which is sent as the request body. Some REST APIs expect DELETE parameters in the URL query string rather than the request body, which can lead to unexpected behavior or API rejection.
gotchaWhile tiny-json-http supports both callbacks and Promises, failing to handle errors in either pattern can lead to unhandled promise rejections or uncaught exceptions, potentially crashing your application.
gotchaThe library does not expose options for configuring request timeouts directly in the public API excerpt provided. This means requests could hang indefinitely in cases of unresponsive servers, affecting application stability.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources