Skip to content

withMirrorFailover ​

Import from: @xbbg/xnews

withMirrorFailover<Value>(baseUrls, attempt): Promise<MirrorOutcome<Value>>

Defined in: src/mirrors.ts (declaration: mirrors.d.ts:89)

Runs attempt against each origin in order and returns the first success.

Only a transport-coded XnewsFetchError advances to the next mirror. A programming error or failed configuration is independent of the selected origin and is rethrown unchanged. A mirror that answers with zero results has answered, and failing over would silently turn one catalog's honest empty page into another catalog's results.

Throws a config-coded error for an empty pool, and when every mirror failed, the last mirror's code with all attempts named in the message.

Type Parameters ​

Value ​

Value

Parameters ​

baseUrls ​

readonly string[]

attempt ​

(baseUrl) => Promise<Value>

Returns ​

Promise<MirrorOutcome<Value>>

Last updated:

xbbg is independent open-source software and is not affiliated with, endorsed by, sponsored by, or approved by Bloomberg Finance L.P.