Skip to content

FluxbaseFetch

new FluxbaseFetch(baseUrl, options): FluxbaseFetch

ParameterType
baseUrlstring
optionsobject
options.debug?boolean
options.headers?Record<string, string>
options.timeout?number

FluxbaseFetch

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

DELETE request

Type ParameterDefault type
Tunknown
ParameterType
pathstring
optionsOmit<FetchOptions, "method">

Promise<T>


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

GET request

Type ParameterDefault type
Tunknown
ParameterType
pathstring
optionsOmit<FetchOptions, "method">

Promise<T>


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

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

Type ParameterDefault type
Tunknown
ParameterType
pathstring
optionsOmit<FetchOptions, "method">

Promise<FetchResponseWithHeaders<T>>


head(path, options): Promise<Headers>

HEAD request

ParameterType
pathstring
optionsOmit<FetchOptions, "method">

Promise<Headers>


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

PATCH request

Type ParameterDefault type
Tunknown
ParameterType
pathstring
body?unknown
options?Omit<FetchOptions, "method" | "body">

Promise<T>


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

POST request

Type ParameterDefault type
Tunknown
ParameterType
pathstring
body?unknown
options?Omit<FetchOptions, "method" | "body">

Promise<T>


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

PUT request

Type ParameterDefault type
Tunknown
ParameterType
pathstring
body?unknown
options?Omit<FetchOptions, "method" | "body">

Promise<T>


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

Make an HTTP request

Type ParameterDefault type
Tunknown
ParameterType
pathstring
optionsFetchOptions

Promise<T>


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

Make an HTTP request and return response with headers

Type ParameterDefault type
Tunknown
ParameterType
pathstring
optionsFetchOptions

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

ParameterType
keystring

void


setAuthToken(token): void

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

ParameterType
tokennull | 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

ParameterType
callbacknull | RefreshTokenCallback

void