cache-fetcher API Reference (JavaScript)
GET
get(url: string, options?: Options): Promise<{data: any, isLoading: boolean, error: unknown}>Fetches data from the given URL using the GET method and optionally caches the result.
Parameters
url: The url endpoint for the requestoptions: (optional) an object of options, based on AxiosRequestConfig (opens in a new tab).
Return Values
data: The response data returned from the serverisLoading: Returnstruewhen request is ongoing, when done it returnsfalseerror: Error thrown from server
POST
post(url: string, body: any, contentType?: string, options?: Options): Promise<{data: any, isLoading: boolean, error: unknown}>Sends data to the given URL using the POST method.
Parameters
url: The url endpoint for the requestbody: The request bodycontentType: (optional) The "Content-Type" header's value, if blank itsapplication/jsonoptions: (optional) an object of options, based on AxiosRequestConfig (opens in a new tab).
Return Values
data: The response data returned from the serverisLoading: Returnstruewhen request is ongoing, when done it returnsfalseerror: Error thrown from server
PUT
put(url: string, body: any, contentType?: string, options?: Options): Promise<{data: any, isLoading: boolean, error: unknown}>Updates data at the given URL using the PUT method.
Parameters
Same as the POST method.
Return Values
data: The response data returned from the serverisLoading: Returnstruewhen request is ongoing, when done it returnsfalseerror: Error thrown from server
DELETE
del(url: string, options?: Options): Promise<{data: any, isLoading: boolean, error: unknown}>Deletes data at the given URL using the DELETE method.
Parameters
The parameters for this are the same as the POST method.
url: The url endpoint for the requestoptions: (optional) an object of options, based on AxiosRequestConfig (opens in a new tab).
Return Values
data: The response data returned from the serverisLoading: Returnstruewhen request is ongoing, when done it returnsfalseerror: Error thrown from server
HEAD
head(url: string, options?: Options): Promise<{headers: any, status: number, error: unknown}>Retrieves the headers and status code from the given URL using the HEAD method.
Parameters
url: The url endpoint for the requestoptions: (optional) an object of options, based on AxiosRequestConfig (opens in a new tab).
Return Values
headers: The response headers returned from the serverstatus: The status code of the responseerror: Error thrown from server
OPTIONS
options(url: string, options?: Options): Promise<{options: any, error: unknown}>Retrieves the communication options from the given URL using the OPTIONS method.
Parameters
url: The url endpoint for the requestoptions: (optional) an object of options, based on AxiosRequestConfig (opens in a new tab).
Return Values
options: The communication options returned from the servererror: Error thrown from server
PATCH
patch(url: string, body: any, contentType?: string, options?: Options): Promise<{data: any, error: unknown}>Updates data to the given URL using the PATCH method.
Parameters
url: The url endpoint for the requestbody: The request bodycontentType: (optional) The "Content-Type" header's value, if blank itsapplication/jsonoptions: (optional) an object of options, based on AxiosRequestConfig (opens in a new tab).
Return Values
data: The response data returned from the servererror: Error thrown from server