The Fetchling class provides a wrapper around the browser fetch() API, storing a reusable request object, and exposing helper functions to access nested sub-resources of the base URL.
Fetchling(init?: FRequestInit,)
Class constructor for a Fetchling instance.
delete(init?: FRequestInit): Promise<FResponse>
Execute a "DELETE" request on the given Fetchling instance, with optional configuration.
Execute a fetch() with the given request and configuration on the Fetchling class.
fetch(init?: FRequestInit): Promise<FResponse>
Execute a fetch() with optional config params. Example:
const api = f("http://foo.com/endpoint", { json: true }); const { data } = await api.fetch({ params: new URLSearchParams({ order_by: "date" }); });
Execute a fetch() with the given request and configuration on the Fetchling class.
get(init?: FRequestInit): Promise<FResponse>
Execute a "GET" request on the given Fetchling instance, with optional configuration.
Internal helper to get the originally configured URL argument for the fetch request.
head(init?: FRequestInit): Promise<FResponse>
Execute a "HEAD" request on the given Fetchling instance, with optional configuration.
patch(init?: FRequestInit): Promise<FResponse>
Execute a "PATCH" request on the given Fetchling instance, with optional configuration.
post(init?: FRequestInit): Promise<FResponse>
Execute a "POST" request on the given Fetchling instance, with optional configuration.
put(init?: FRequestInit): Promise<FResponse>
Execute a "PUT" request on the given Fetchling instance, with optional configuration.
create(init?: FRequestInit | undefined,): Fetchling
Factory method to create a new hybrid type Fetchling instance