machinepack-http provides a simple, `jQuery.get()`-like interface for sending HTTP requests, scraping webpages, and streaming data within Node.js and Sails.js applications. Currently at version 9.0.0, this library aims for immediate productivity in common cloud API interactions. It differentiates itself by offering robust error negotiation, distinguishing between network failures (e.g., offline, server down) and deliberate server errors (non-2xx status codes), and providing low-level streaming access to responses. The package is maintained by the Sails.js core team and follows the node-machine specification, acting as a higher-level wrapper around an underlying HTTP client. Its release cadence is tied to the Sails.js ecosystem, focusing on stability and integration.
npm install machinepack-httpVerified import paths — ran on the pinned version, not inferred.
Demonstrates making a GET request to a target URL, handling both network errors and non-2xx HTTP status code responses, and parsing a successful JSON response.
Consider migrating to a modern, maintained HTTP client such as `node-fetch`, `axios`, or the built-in Node.js `undici`. If `machinepack-http` is critical, monitor its updates for a transition away from `request`.
Familiarize yourself with the node-machine specification and the `.exec()` pattern. Always chain `.exec()` after calling a machine, providing handlers for all expected exit states.
Always provide distinct handlers for both the `error` and `non2xx` exits in your `.exec()` call to ensure robust error management.
Evaluate alternatives to `machinepack-http` or be prepared for potential future breaking changes if it undergoes a major rewrite to replace its `request` dependency.
Ensure `const Http = require('machinepack-http');` is present and that you are calling methods like `Http.get()` on the required object.Verify the target URL and port are correct and that the server is online and accessible. Check firewall rules on both client and server.
Check the hostname for typos, ensure your network has access to a DNS server, or try accessing a different, known-good URL.
Refer to the `node-machine.org` documentation for `machinepack-http` to see the list of available machines and their correct names. Ensure correct casing.