Registry / http-networking / handy-http

handy-http

JSON →
library1.0.2jsnpmunverified

Simple wrapper for native NodeJS http[s].request providing a flexible interface for making HTTP/HTTPS requests. Stable version 1.0.2. Lightweight copy-paste reducer supporting various data types (plain objects, Buffer, ReadableStream), multipart file uploads, proxy requests, and automatic JSON parsing. Keeps access to native NodeJS http.ClientRequest events. Less feature-rich than axios or request but minimal and dependency-free.

npm install handy-http
INSTALL
IMPORT
SIG · HANDY-HTTP
H
handy-http
http-networkingjavascriptv1.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

HTTPClient
var HTTPClient = require('handy-http'); var client = new HTTPClient();
var client = new require('handy-http')();
CommonJS only. Must instantiate with 'new'.
client.open
client.open({ url: 'http://example.com', method: 'POST', data: { key: 'value' } }, callback);
client.open('http://example.com', {}, callback);
Second argument is callback, not options. Options go in first argument as object or URL string.
request object
var request = client.open({ url: '...' }, callback); request.on('socket', function(socket) { /* ... */ });
client.open({ url: '...' }, callback).on('socket', ...);
client.open returns the native NodeJS http.ClientRequest object; can attach event listeners.

Shows GET and POST requests with error handling using handy-http. Demonstrates simple URL string and options object usage.

var HTTPClient = require('handy-http'); var client = new HTTPClient(); // Simple GET request client.open('http://jsonplaceholder.typicode.com/posts/1', function(err, res) { if (err) { console.error(err); return; } console.log('Response:', res); }); // POST request with data client.open({ url: 'http://jsonplaceholder.typicode.com/posts', method: 'POST', data: { title: 'foo', body: 'bar', userId: 1 } }, function(err, res) { if (err) { console.error(err); return; } console.log('Created:', res); });
Debug
Known issues
gotchaCallback receives error first (Node.js convention).
fix
Always check first argument for error before using response.
affects: *
gotchaMust use 'new' keyword when instantiating HTTPClient. Forgetting 'new' may cause errors or unexpected behavior.
fix
Always do: var client = new HTTPClient();
affects: *
gotchaData as Buffer or Stream sends raw binary without content-type; caller must set appropriate headers.
fix
Set 'content-type' header explicitly when sending Buffer/Stream.
affects: *
gotchaMultipart upload requires files array and headers['content-type'] = 'multipart/form-data'. If not set, data won't be multipart.
fix
Explicitly set headers.content-type to 'multipart/form-data' when using files.
affects: *
gotchaProxy support is basic; no authentication or HTTPS proxy handling.
fix
Use a more feature-rich library like 'request' or 'axios' for advanced proxy needs.
affects: *
Errors
Common errors & fixes
TypeError: HTTPClient is not a constructor
Forgetting 'new' when instantiating HTTPClient.
fix
Use 'new HTTPClient()' or 'new (require('handy-http'))()'.
Unhandled 'error' event
No error callback provided; request fails silently.
fix
Pass a callback function with two parameters: (err, res).
TypeError: Cannot read property 'on' of undefined
client.open returns undefined if not called correctly (e.g., wrong arguments).
fix
Ensure first argument is a string URL or options object, second is callback.
Upgrade
Version history
1.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
handy-http — npm install handy-http · libregistry