{"id":25737,"library":"http-service","title":"http-service","description":"A simple Node.js module wrapping Node's native http/https module, targeting JSON data exchange between servers. Version 1.1.3 provides GET, POST, PUT, DELETE requests with both callback and Promise support. It allows base URL initialization and can be subclassed for custom service APIs. Limited documentation and low maintenance activity; no significant updates since 2018. Suitable for simple JSON-based server-to-server communication but lacks advanced features like interceptors, retries, or streaming support found in Axios or Got.","status":"maintenance","version":"1.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/FDIM/http-service","tags":["javascript","http","http-service"],"install":[{"cmd":"npm install http-service","lang":"bash","label":"npm"},{"cmd":"yarn add http-service","lang":"bash","label":"yarn"},{"cmd":"pnpm add http-service","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is CJS only, no ESM exports. Use require() exclusively.","wrong":"import HttpService from 'http-service';","symbol":"HttpService","correct":"const HttpService = require('http-service');"},{"note":"init() is an instance method for later initialization, not a static method. The constructor accepts an optional URL string.","wrong":"HttpService.init('https://example.com');","symbol":"Constructor new HttpService(url)","correct":"const service = new HttpService('https://example.com');"},{"note":"If no callback is provided, the method returns a Promise. However, the Promise is not fully documented; prefer using callbacks.","wrong":"service.get('/path', {query: 1}).then();","symbol":"Instance methods (get, post, put, delete)","correct":"service.get('/path', {query: 1}, callback);"}],"quickstart":{"code":"const HttpService = require('http-service');\n\nconst service = new HttpService();\nservice.init(process.env.API_URL || 'http://localhost:3000');\n\n// GET with callback\nservice.get('/data', {limit: 10}, (err, data) => {\n  if (err) console.error('Error:', err);\n  else console.log('Data:', data);\n});\n\n// POST with Promise (no callback)\nservice.post('/data', {}, {name: 'test'})\n  .then(data => console.log('Created:', data))\n  .catch(err => console.error('Error:', err));\n\n// DELETE\nservice.delete('/data/1', {}, (err, result) => {\n  if (err) console.error('Delete failed:', err);\n  else console.log('Deleted:', result);\n});","lang":"javascript","description":"Shows basic usage: creating an instance, initializing with a base URL, and performing GET, POST, and DELETE requests with callbacks and Promises."},"warnings":[{"fix":"Always validate the URL before calling init, and use try-catch around instantiation.","message":"The `init` method does not validate the URL or handle protocol errors gracefully; invalid URLs may cause unhandled exceptions.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Choose one pattern (prefer callbacks for consistency) and stick to it.","message":"Callbacks are the primary pattern but Promise support exists; mixing both in the same codebase can lead to confusion.","severity":"deprecated","affected_versions":">=1.1.0"},{"fix":"Set environment variable NODE_TLS_REJECT_UNAUTHORIZED=0 (not recommended for production) or use a custom agent.","message":"The library does not support HTTPS strict SSL by default; self-signed certificates may cause failures unless NODE_TLS_REJECT_UNAUTHORIZED is set.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Serialize nested query parameters manually using a library like qs or querystring.","message":"Query parameters are passed as an object, but the library does not deeply serialize nested objects; only first-level keys are sent.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install http-service' in your project directory.","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'http-service'"},{"fix":"Create an instance: const service = new HttpService(); then call service.get().","cause":"Trying to call method on the class itself instead of an instance.","error":"TypeError: service.get is not a function"},{"fix":"Ensure the URL is correct and the server is reachable. Use an IP or valid domain.","cause":"Invalid or unreachable hostname passed to init.","error":"Error: getaddrinfo ENOTFOUND"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}