Skip to content

FluxbaseFetch

new FluxbaseFetch(baseUrl, options?): FluxbaseFetch

Parameter Type
baseUrl string
options { debug?: boolean; headers?: Record<string, string>; timeout?: number; }
options.debug? boolean
options.headers? Record<string, string>
options.timeout? number

FluxbaseFetch

delete<T>(path, options?): Promise<T>

DELETE request

Type Parameter Default type
T unknown
Parameter Type
path string
options Omit<FetchOptions, "method">

Promise<T>


get<T>(path, options?): Promise<T>

GET request

Type Parameter Default type
T unknown
Parameter Type
path string
options Omit<FetchOptions, "method">

Promise<T>


getBaseUrl(): string

string


getBlob(path, options?): Promise<Blob>

GET request that returns response as Blob (for file downloads)

Parameter Type
path string
options Omit<FetchOptions, "method">

Promise<Blob>


getDefaultHeaders(): Record<string, string>

Record<string, string>


getWithHeaders<T>(path, options?): Promise<FetchResponseWithHeaders<T>>

GET request that returns response with headers (for count queries)

Type Parameter Default type
T unknown
Parameter Type
path string
options Omit<FetchOptions, "method">

Promise<FetchResponseWithHeaders<T>>


head(path, options?): Promise<Headers>

HEAD request

Parameter Type
path string
options Omit<FetchOptions, "method">

Promise<Headers>


patch<T>(path, body?, options?): Promise<T>

PATCH request

Type Parameter Default type
T unknown
Parameter Type
path string
body? unknown
options? Omit<FetchOptions, "method" | "body">

Promise<T>


post<T>(path, body?, options?): Promise<T>

POST request

Type Parameter Default type
T unknown
Parameter Type
path string
body? unknown
options? Omit<FetchOptions, "method" | "body">

Promise<T>


postWithHeaders<T>(path, body?, options?): Promise<FetchResponseWithHeaders<T>>

POST request that returns response with headers (for POST-based queries with count)

Type Parameter Default type
T unknown
Parameter Type
path string
body? unknown
options? Omit<FetchOptions, "method" | "body">

Promise<FetchResponseWithHeaders<T>>


put<T>(path, body?, options?): Promise<T>

PUT request

Type Parameter Default type
T unknown
Parameter Type
path string
body? unknown
options? Omit<FetchOptions, "method" | "body">

Promise<T>


removeHeader(name): void

Remove a custom header

Parameter Type
name string

void


request<T>(path, options): Promise<T>

Make an HTTP request

Type Parameter Default type
T unknown
Parameter Type
path string
options FetchOptions

Promise<T>


requestWithHeaders<T>(path, options): Promise<FetchResponseWithHeaders<T>>

Make an HTTP request and return response with headers

Type Parameter Default type
T unknown
Parameter Type
path string
options FetchOptions

Promise<FetchResponseWithHeaders<T>>


setAnonKey(key): void

Set the anon key for fallback authentication When setAuthToken(null) is called, the Authorization header will be restored to use this anon key instead of being deleted

Parameter Type
key string

void


setAuthToken(token): void

Update the authorization header When token is null, restores to anon key if available

Parameter Type
token string | null

void


setBeforeRequestCallback(callback): void

Register a callback to be called before every request. The callback receives the headers object and can modify it in place. This is useful for dynamically injecting headers at request time.

Parameter Type
callback BeforeRequestCallback | null

void


setHeader(name, value): void

Set a custom header on all requests

Parameter Type
name string
value string

void


setRefreshTokenCallback(callback): void

Register a callback to refresh the token when a 401 error occurs The callback should return true if refresh was successful, false otherwise

Parameter Type
callback RefreshTokenCallback | null

void