SetSharedOptions

module:balena-sdk~setSharedOptions(options)

Set options that are used by calls to fromSharedOptions(). The options accepted are the same as those used in the main SDK factory function. If you use this method, it should be called as soon as possible during app startup and before any calls to fromSharedOptions() are made.

Kind: inner function Summary: Set shared default options Access: public

Param
Type
Default
Description

options

Object

The shared default options

[options.apiUrl]

String

'https://api.balena-cloud.com/'

the balena API url to use.

[options.builderUrl]

String

'https://builder.balena-cloud.com/'

the balena builder url to use.

[options.deviceUrlsBase]

String

'balena-devices.com'

the base balena device API url to use.

[options.requestLimit]

Number

the number of requests per requestLimitInterval that the SDK should respect.

[options.requestLimitInterval]

Number

60000

the timespan that the requestLimit should apply to in milliseconds, defaults to 60000 (1 minute).

[options.retryRateLimitedRequests]

Boolean | function

false

Determines whether to automatically retry requests that are failing with a 429 Too Many Requests status code and that include a numeric Retry-After response header.

  • If false, rate-limited requests will not be retried, and the rate limit error will be propagated.

  • If true, all rate-limited requests will be retried after the duration specified by the Retry-After header.

  • If a function (retryAfterMs: number) => boolean is provided, it will be called with the retry duration in ms and the request will be retried only when true is returned.

[options.dataDirectory]

String | False

'$HOME/.balena'

ignored in the browser unless false, the directory where the user settings are stored, normally retrieved like require('balena-settings-client').get('dataDirectory'). Providing false creates an isolated in-memory instance.

[options.isBrowser]

Boolean

the flag to tell if the module works in the browser. If not set will be computed based on the presence of the global window value.

[options.debug]

Boolean

when set will print some extra debug information.

Example

import { setSharedOptions } from 'balena-sdk';
setSharedOptions({
	apiUrl: 'https://api.balena-cloud.com/',
	builderUrl: 'https://builder.balena-cloud.com/',
	isBrowser: true,
});

Last updated

Was this helpful?