balena-request is a low-level HTTP client specifically designed for making requests to Balena servers. It is not intended for direct use by end-users, but rather as an internal dependency for other Balena-io modules, such as the balena SDK. The current stable version is 14.2.0, with frequent patch and minor releases, indicating active development. Key differentiators include its tight integration with the Balena ecosystem, requiring an instantiated `balena-auth` instance for authentication, and providing features like request interceptors, streaming capabilities, and automatic handling of authorization. It supports both Node.js (requiring `>=18.0.0`) and browser environments, though the `isBrowser` option has been deprecated in recent versions. The module exposes a factory function to create a request instance, enabling configurable behavior like debug logging and retries.
npm install balena-requestVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import `balena-request`, create a client instance with a mocked `balena-auth` dependency, and execute a simple GET request to the Balena API's `/ping` endpoint.
For most use cases, use the `balena-sdk` package (`npm install --save balena-sdk`) which wraps `balena-request` with a higher-level API.
Remove the `isBrowser` option from your `balenaRequest` factory configuration.
Review any custom URL parsing or manipulation logic within interceptors or downstream modules that might implicitly rely on Node.js `url` module behavior. Ensure compatibility with the WHATWG URL API standard.
Ensure that your environment (especially older Node.js versions or specific browser targets) provides a compatible `fetch` implementation or include necessary polyfills like `abortcontroller-polyfill` if using `AbortController` for request cancellation.
Ensure an instantiated `balena-auth` instance is passed as the `auth` option: `balenaRequest({ auth: myAuthInstance, ... })`.Verify your bundling configuration (e.g., Webpack, Rollup) for Balena modules, ensuring proper resolution and transpilation. For Balena Etcher specific issues, try running the application as an administrator or using an alternative flashing tool if the issue persists.
Provide an `auth` instance of `balena-auth` in the options object: `balenaRequest({ auth: balenaAuthInstance, debug: false })`.