Node.js HTTP Client Wrapper

0.0.5 · abandoned · verified Sun Apr 19

This package, `node-http`, provides a minimalistic interface for making HTTP requests within Node.js applications. Originally published over 12 years ago (latest version 0.0.5 from October 2013), it aims to unify the HTTP request process with a chainable API for setting URL, headers, data, and method, alongside event-based callbacks for completion, success, and failure. Due to its age and lack of updates, it is considered abandoned. It exclusively uses CommonJS syntax and does not support modern JavaScript features like Promises or async/await, nor does it officially support contemporary Node.js versions or ESM. Its release cadence was effectively one-off, with no subsequent development. Key differentiators at the time might have been its simplified event-driven approach, but it is now severely outdated compared to actively maintained alternatives like `axios` or Node.js's native `fetch` API.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates initializing the client, making a GET request, a POST request with data, and handling responses and specific HTTP status events using callbacks.

const NodeHttp = require('node-http');
const nodeHttp = new NodeHttp();

// Example: Perform a GET request
nodeHttp.GET('http://example.com/data', function (response) {
  console.log('Success:', response.responseText);
  console.log('Status Code:', response.statusCode);
}).fail(function (error) {
  console.error('Failed to fetch data:', error);
});

// Example: Perform a POST request with data
nodeHttp.POST('http://example.com/submit', { key: 'value', id: 123 }, function (response) {
  console.log('Post Success:', response.responseText);
}).on('error', function(err) {
  console.error('Post Error:', err);
});

// Example: Listening for specific status codes
nodeHttp.on(200, function(response) {
  console.log('HTTP 200 OK received for a request.');
});

nodeHttp.on('Not Found', function(response) {
  console.error('HTTP 404 Not Found received.');
});

view raw JSON →