{"id":18406,"library":"handy-http","title":"handy-http","description":"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.","status":"maintenance","version":"1.0.2","language":"javascript","source_language":"en","source_url":"git://github.com/dimik/node-handy-http","tags":["javascript","http","https"],"install":[{"cmd":"npm install handy-http","lang":"bash","label":"npm"},{"cmd":"yarn add handy-http","lang":"bash","label":"yarn"},{"cmd":"pnpm add handy-http","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"CommonJS only. Must instantiate with 'new'.","wrong":"var client = new require('handy-http')();","symbol":"HTTPClient","correct":"var HTTPClient = require('handy-http');\nvar client = new HTTPClient();"},{"note":"Second argument is callback, not options. Options go in first argument as object or URL string.","wrong":"client.open('http://example.com', {}, callback);","symbol":"client.open","correct":"client.open({ url: 'http://example.com', method: 'POST', data: { key: 'value' } }, callback);"},{"note":"client.open returns the native NodeJS http.ClientRequest object; can attach event listeners.","wrong":"client.open({ url: '...' }, callback).on('socket', ...);","symbol":"request object","correct":"var request = client.open({ url: '...' }, callback);\nrequest.on('socket', function(socket) { /* ... */ });"}],"quickstart":{"code":"var HTTPClient = require('handy-http');\nvar client = new HTTPClient();\n\n// Simple GET request\nclient.open('http://jsonplaceholder.typicode.com/posts/1', function(err, res) {\n  if (err) { console.error(err); return; }\n  console.log('Response:', res);\n});\n\n// POST request with data\nclient.open({\n  url: 'http://jsonplaceholder.typicode.com/posts',\n  method: 'POST',\n  data: { title: 'foo', body: 'bar', userId: 1 }\n}, function(err, res) {\n  if (err) { console.error(err); return; }\n  console.log('Created:', res);\n});","lang":"javascript","description":"Shows GET and POST requests with error handling using handy-http. Demonstrates simple URL string and options object usage."},"warnings":[{"fix":"Always check first argument for error before using response.","message":"Callback receives error first (Node.js convention).","severity":"gotcha","affected_versions":"*"},{"fix":"Always do: var client = new HTTPClient();","message":"Must use 'new' keyword when instantiating HTTPClient. Forgetting 'new' may cause errors or unexpected behavior.","severity":"gotcha","affected_versions":"*"},{"fix":"Set 'content-type' header explicitly when sending Buffer/Stream.","message":"Data as Buffer or Stream sends raw binary without content-type; caller must set appropriate headers.","severity":"gotcha","affected_versions":"*"},{"fix":"Explicitly set headers.content-type to 'multipart/form-data' when using files.","message":"Multipart upload requires files array and headers['content-type'] = 'multipart/form-data'. If not set, data won't be multipart.","severity":"gotcha","affected_versions":"*"},{"fix":"Use a more feature-rich library like 'request' or 'axios' for advanced proxy needs.","message":"Proxy support is basic; no authentication or HTTPS proxy handling.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use 'new HTTPClient()' or 'new (require('handy-http'))()'.","cause":"Forgetting 'new' when instantiating HTTPClient.","error":"TypeError: HTTPClient is not a constructor"},{"fix":"Pass a callback function with two parameters: (err, res).","cause":"No error callback provided; request fails silently.","error":"Unhandled 'error' event"},{"fix":"Ensure first argument is a string URL or options object, second is callback.","cause":"client.open returns undefined if not called correctly (e.g., wrong arguments).","error":"TypeError: Cannot read property 'on' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}