{"id":18796,"library":"smart-http","title":"smart-http","description":"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.","status":"active","version":"1.2.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","smart-http"],"install":[{"cmd":"npm install smart-http","lang":"bash","label":"npm"},{"cmd":"yarn add smart-http","lang":"bash","label":"yarn"},{"cmd":"pnpm add smart-http","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only since v1.0; no CommonJS support.","wrong":"const http = require('smart-http')","symbol":"default","correct":"import http from 'smart-http'"},{"note":"Named export available for destructuring.","wrong":"","symbol":"request","correct":"import { request } from 'smart-http'"},{"note":"Class constructor is the default export, not a named export.","wrong":"import { SmartHttp } from 'smart-http'","symbol":"SmartHttp","correct":"import SmartHttp from 'smart-http'"}],"quickstart":{"code":"import http from 'smart-http';\n\nasync function fetchData() {\n  try {\n    const response = await http.get('https://api.example.com/data', {\n      headers: { 'Authorization': `Bearer ${process.env.API_KEY ?? ''}` }\n    });\n    console.log(response.data);\n  } catch (error) {\n    console.error('Request failed:', error);\n  }\n}\n\nfetchData();","lang":"typescript","description":"Shows a basic GET request with async/await, environment variable for auth, and error handling."},"warnings":[{"fix":"Declare module augmentation or use @types/smart-http if available.","message":"Package has no exported types; TypeScript users must define their own interfaces for request/response.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Pass a signal option from AbortController.timeout() to enable cancellation.","message":"The .get/.post methods do not support request cancellation or timeout by default; configure via AbortController manually.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Switch to promise-based API for new code.","message":"The 'data' event listener pattern is deprecated; use async/await or promise chaining instead.","severity":"deprecated","affected_versions":">=1.1.0"},{"fix":"Check response.ok and then JSON.parse(response.data) for non-2xx responses.","message":"Response body is not automatically JSON-parsed for status codes outside 2xx; manual parsing required.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use 'form-data' package and pipe it to a request.","message":"Multipart form data is not supported natively; use FormData polyfill or another library.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use import http from 'smart-http' instead of const http = require('smart-http').","cause":"Attempting to use require() in an ESM environment or wrong import style.","error":"TypeError: http.get is not a function"},{"fix":"Convert the importing module to ESM (use 'import' statements) or use dynamic import().","cause":"Trying to require() an ESM-only package from CommonJS.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"},{"fix":"Declare a module augmentation for 'smart-http' or cast response as any.","cause":"TypeScript does not have type definitions for the response.","error":"Property 'data' does not exist on type 'SmartHttpResponse'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}