agent-phin is an ultra-lightweight Node.js HTTP client, forked from the popular phin library, specifically designed to add robust HTTP agent support. It is currently at version 1.0.4 and appears to maintain a release cadence tied to the introduction of specific features, such as the agent support in v1.0.1. Its primary differentiator is its minimal footprint, being significantly smaller than many common HTTP clients like request, axios, or node-fetch, while still providing essential features like POST requests, JSON parsing, and configurable timeouts. The key addition over the original phin is the native capability to utilize custom `http.Agent` or `https.Agent` instances, enabling features like connection pooling (KeepAlive) or proxy integration via libraries like `https-proxy-agent`. It supports both Promise-based and unpromisified (callback-style) API calls, catering to different asynchronous programming preferences in Node.js environments.
npm install agent-phinVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to make a POST request using `agent-phin` with a `https.Agent` configured for KeepAlive, showcasing its primary differentiating feature for efficient connection management.
Wrap `await p(...)` calls in an `async` function or chain `.then()` and `.catch()` to the Promise returned by `p()`.
Review the `agent-phin` GitHub repository for specific updates and compatibility notes if migrating from or considering the original `phin`.
Ensure `agent.destroy()` is called on your custom agent instance, typically in a `finally` block or when your application is shutting down, to properly close persistent connections.
For Node.js projects, use `const p = require('agent-phin');`. If you must use ESM `import`, ensure your project is configured for ESM, or consider an intermediary CommonJS wrapper.Declare the function containing `await` as `async function` or handle the returned Promise using `.then()` and `.catch()`.
Ensure you have `const p = require('agent-phin');` at the beginning of your script.Verify that your proxy server is running and accessible at the specified address and port. Check network connectivity, firewall rules, or proxy configuration.