Registry / http-networking / smart-http

smart-http

JSON →
library1.2.0jsnpmunverified

A minimal HTTP client library for Node.js with a focus on simplicity and ease of use. Version 1.2.0 is the current stable release. The package provides basic HTTP request functionality with automatic JSON parsing, support for custom headers, and stream handling. It differentiates itself by requiring no external dependencies and offering a straightforward API for common use cases, though it lacks advanced features like interceptors or cancellation found in larger libraries. Released on an ad-hoc cadence with no recent updates.

npm install smart-http
INSTALL
IMPORT
SIG · SMART-HTTP
S
smart-http
http-networkingjavascriptv1.2.0
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.

default
import http from 'smart-http'
const http = require('smart-http')
ESM-only since v1.0; no CommonJS support.
request
import { request } from 'smart-http'
Named export available for destructuring.
SmartHttp
import SmartHttp from 'smart-http'
import { SmartHttp } from 'smart-http'
Class constructor is the default export, not a named export.

Shows a basic GET request with async/await, environment variable for auth, and error handling.

import http from 'smart-http'; async function fetchData() { try { const response = await http.get('https://api.example.com/data', { headers: { 'Authorization': `Bearer ${process.env.API_KEY ?? ''}` } }); console.log(response.data); } catch (error) { console.error('Request failed:', error); } } fetchData();
Debug
Known issues
gotchaPackage has no exported types; TypeScript users must define their own interfaces for request/response.
fix
Declare module augmentation or use @types/smart-http if available.
affects: >=1.0.0
gotchaThe .get/.post methods do not support request cancellation or timeout by default; configure via AbortController manually.
fix
Pass a signal option from AbortController.timeout() to enable cancellation.
affects: >=1.0.0
deprecatedThe 'data' event listener pattern is deprecated; use async/await or promise chaining instead.
fix
Switch to promise-based API for new code.
affects: >=1.1.0
gotchaResponse body is not automatically JSON-parsed for status codes outside 2xx; manual parsing required.
fix
Check response.ok and then JSON.parse(response.data) for non-2xx responses.
affects: >=1.0.0
gotchaMultipart form data is not supported natively; use FormData polyfill or another library.
fix
Use 'form-data' package and pipe it to a request.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: http.get is not a function
Attempting to use require() in an ESM environment or wrong import style.
fix
Use import http from 'smart-http' instead of const http = require('smart-http').
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Trying to require() an ESM-only package from CommonJS.
fix
Convert the importing module to ESM (use 'import' statements) or use dynamic import().
Property 'data' does not exist on type 'SmartHttpResponse'
TypeScript does not have type definitions for the response.
fix
Declare a module augmentation for 'smart-http' or cast response as any.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
3 hits · last 30 days
node
2
OpenAI (training)
1
Resources
smart-http — npm install smart-http · libregistry