Tiny JSON HTTP Client

7.5.1 · active · verified Tue Apr 21

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.

Common errors

Warnings

Install

Imports

Quickstart

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
    }
  }
})();

view raw JSON →