Planck HTTP Fetch (current version 1.7.4) is a lightweight, promise-based library for making HTTP and HTTPS requests within Node.js environments. It offers a fluent, chainable API that simplifies the configuration of requests, allowing developers to easily set parameters such as timeouts, custom headers, and basic authentication details. A notable feature is its automatic handling of HTTP 307 temporary redirects, which was introduced in version 1.7.2, enhancing its robustness for web interactions. The library implicitly determines the HTTP method (GET or POST) based on the presence of a request body, streamlining its usage for common data exchange patterns. It ships with comprehensive TypeScript type definitions, providing strong type checking and IDE support. While a specific release cadence isn't detailed, the package appears to be actively maintained, focusing on a straightforward and developer-friendly approach to network requests, differentiating itself through its minimalist API and direct control over core fetch functionalities.
npm install planck-http-fetchVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to perform both POST and GET requests using `planck-http-fetch`. It shows how to chain methods for setting timeouts, custom headers, and basic authentication, and how the library implicitly determines the HTTP method based on the presence of a request body.
Always explicitly specify the `contentType` parameter in `.fetch(data, contentType)` when sending non-JSON data, or ensure your server is configured to handle `application/json` by default.
Avoid using `.unauthorized()` in production environments. Ensure your HTTPS certificates are properly issued and trusted by your system's root CAs. If custom CAs are needed, use Node.js environment variables like `NODE_EXTRA_CA_CERTS`.
Be mindful of the `data` parameter. If you explicitly need a GET request, ensure `data` is omitted or `undefined`. For POST, always provide `data`. The library does not currently offer an explicit method to force GET or POST if data is present.
Ensure your project is configured for ES Modules (e.g., `"type": "module"` in `package.json`) and use `import { Fetch } from 'planck-http-fetch';`. If you must use CommonJS, consider using dynamic import `import('planck-http-fetch').then(m => new m.Fetch())` (requires Node.js >=13).Increase the timeout duration using `.timeout(milliseconds)` in your chain (e.g., `.timeout(15000)` for 15 seconds). Verify the target URL is correct, the server is running, and there are no network issues (e.g., firewall, proxy, DNS resolution) blocking the connection from your environment.
No dependency data recorded yet.