FluxbaseFetch
Constructors
Section titled “Constructors”new FluxbaseFetch()
Section titled “new FluxbaseFetch()”new FluxbaseFetch(
baseUrl,options):FluxbaseFetch
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
baseUrl | string |
options | object |
options.debug? | boolean |
options.headers? | Record<string, string> |
options.timeout? | number |
Returns
Section titled “Returns”Methods
Section titled “Methods”delete()
Section titled “delete()”delete<
T>(path,options):Promise<T>
DELETE request
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | string |
options | Omit<FetchOptions, "method"> |
Returns
Section titled “Returns”Promise<T>
get<
T>(path,options):Promise<T>
GET request
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | string |
options | Omit<FetchOptions, "method"> |
Returns
Section titled “Returns”Promise<T>
getWithHeaders()
Section titled “getWithHeaders()”getWithHeaders<
T>(path,options):Promise<FetchResponseWithHeaders<T>>
GET request that returns response with headers (for count queries)
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | string |
options | Omit<FetchOptions, "method"> |
Returns
Section titled “Returns”Promise<FetchResponseWithHeaders<T>>
head()
Section titled “head()”head(
path,options):Promise<Headers>
HEAD request
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | string |
options | Omit<FetchOptions, "method"> |
Returns
Section titled “Returns”Promise<Headers>
patch()
Section titled “patch()”patch<
T>(path,body?,options?):Promise<T>
PATCH request
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | string |
body? | unknown |
options? | Omit<FetchOptions, "method" | "body"> |
Returns
Section titled “Returns”Promise<T>
post()
Section titled “post()”post<
T>(path,body?,options?):Promise<T>
POST request
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | string |
body? | unknown |
options? | Omit<FetchOptions, "method" | "body"> |
Returns
Section titled “Returns”Promise<T>
put<
T>(path,body?,options?):Promise<T>
PUT request
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | string |
body? | unknown |
options? | Omit<FetchOptions, "method" | "body"> |
Returns
Section titled “Returns”Promise<T>
request()
Section titled “request()”request<
T>(path,options):Promise<T>
Make an HTTP request
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | string |
options | FetchOptions |
Returns
Section titled “Returns”Promise<T>
requestWithHeaders()
Section titled “requestWithHeaders()”requestWithHeaders<
T>(path,options):Promise<FetchResponseWithHeaders<T>>
Make an HTTP request and return response with headers
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
path | string |
options | FetchOptions |
Returns
Section titled “Returns”Promise<FetchResponseWithHeaders<T>>
setAnonKey()
Section titled “setAnonKey()”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
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
key | string |
Returns
Section titled “Returns”void
setAuthToken()
Section titled “setAuthToken()”setAuthToken(
token):void
Update the authorization header When token is null, restores to anon key if available
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
token | null | string |
Returns
Section titled “Returns”void
setRefreshTokenCallback()
Section titled “setRefreshTokenCallback()”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
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
callback | null | RefreshTokenCallback |
Returns
Section titled “Returns”void