Skip to main content
Back to Browser

createHttpClientFetcher()

createHttpClientFetcher builds a fetch-shaped function backed by the SDK's shared FetchHttpClient singleton (the same instance auth.getHttpClient() returns), so it attaches the access token the way auth.httpRequest() does. Pass its return value as updateMeCredentials()'s fetcher; without one, the request goes out unauthenticated.

This is what @thunderid/react and @thunderid/vue use internally to wire updateMeCredentials to their own HTTP client. A vanilla app can reach for it too, as an alternative to hand-rolling a fetcher from auth.getAccessToken(); either approach works.

FetchHttpClient.request throws on a non-2xx response rather than resolving it. This adapter catches that and reconstructs a Response-shaped object from the thrown error, so the core function sees the real status and body instead of treating every failure as a network error. A genuine network error (no response attached) still propagates.

Signature

createHttpClientFetcher(instanceId?: number): (url: string, config: RequestInit) => Promise<Response>

Parameters

ParameterTypeDefaultDescription
instanceIdnumber0Which FetchHttpClient instance to use, for apps running multiple SDK instances on the same page.

Returns

(url: string, config: RequestInit) => Promise<Response>

Usage

import { createHttpClientFetcher, updateMeCredentials } from '@thunderid/browser'

await updateMeCredentials({
baseUrl,
payload: { password: newValue },
fetcher: createHttpClientFetcher(), // instanceId defaults to 0
})

Explore with AI

ThunderID LogoThunderID Logo

Product

DocsAPIsSDKs
© Copyright Linux Foundation Europe.For web site terms of use, trademark policy and other project policies please see https://linuxfoundation.eu/en/policies.