http-call is a lightweight, promise-based HTTP client designed for making RESTful API requests. Maintained by Heroku, it provides a fluent interface for common HTTP methods (GET, POST, PUT, DELETE) and simplifies interaction with JSON APIs by automatically converting responses. The current stable version is 5.5.1, with a release cadence that includes regular bug fixes and minor feature enhancements. Key differentiators include built-in TypeScript support, automatic JSON parsing, and a focus on clean, asynchronous API consumption, making it suitable for modern Node.js applications that require robust HTTP communication without extensive configuration. It is widely used within the Heroku ecosystem for interacting with platform services.
npm install http-callVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to make a GET request to the GitHub API, handling authentication, automatic JSON parsing, and TypeScript type inference for the response body. It includes error handling and shows how to use environment variables for sensitive data.
Review your application's network call expectations. If a longer or infinite timeout is required, explicitly set the `timeout` option in your request configuration: `HTTP.get('/slow-api', { timeout: 60000 })` for 60 seconds or `timeout: 0` for no timeout.Standardize on a single module system across your application. For new projects, prefer ES Modules (set `"type": "module"` in `package.json`). If using CommonJS, ensure all imported packages are compatible or use dynamic `await import()` for ESM-only dependencies.
Always use `await` with `HTTP` calls within an `async` function, or chain `.then()` and `.catch()` appropriately to handle both successful responses and errors. Ensure all asynchronous code paths are robustly handled to prevent unexpected application crashes.
If your project is ES Module-based, use `import { HTTP } from 'http-call'`. If your project is CommonJS, ensure your bundler/TypeScript configuration is correctly set up to consume dual-package formats, or ensure you are on a Node.js version that properly handles CJS-importing-ESM interop (typically Node.js 12.20+ or 14.13+ with `--experimental-json-modules` flag, though general CJS `require` of ESM is still a hard error without dynamic `import()`). The most reliable fix is to migrate to ESM if possible or use dynamic imports.Ensure you are correctly destructuring `HTTP` from the module: `import { HTTP } from 'http-call'` or `const { HTTP } = require('http-call')`. If it's still failing, check if another package named `http-call` is accidentally being imported or if the installation is corrupted.Ensure all options passed to `HTTP` methods or the configuration object conform to the expected TypeScript types. For `timeout`, provide a `number` representing milliseconds or `0` for no timeout: `await HTTP.get(url, { timeout: 5000 })`.No dependency data recorded yet.