Endpoint

Source
import { Endpoint } from "@prestojs/rest";
Endpoint<ReturnT = any>

Examples

Simple usage with useAsync

Passing query parameters with useAsync

Integrating pagination

API

Constructor

new Endpoint(urlPattern,?options)
Source

Arguments:

ArgumentTypeDescription
*urlPatternstring|UrlPattern
options
An object with the properties below
options.baseUrlstring
options.bodynull|BodyInit
options.cacheRequestCache
options.credentialsRequestCredentials
options.decodeBody
options.getMiddleware
options.headersHeadersInit|Record
options.integritystring
options.keepaliveboolean
options.methodstring
options.middleware(|)[]
options.modeRequestMode
options.paginator|null
options.redirectRequestRedirect
options.referrerstring
options.referrerPolicyReferrerPolicy
options.resolveUrl
options.signalnull|AbortSignal
options.windownull

Methods

decodeBody(res)
Source

Arguments:

ArgumentTypeDescription
*resResponse
Returns:any
execute(?options)
Source

Arguments:

ArgumentTypeDescription
options
An object with the properties below
options.bodynull|BodyInit
options.cacheRequestCache
options.credentialsRequestCredentials
options.headersHeadersInit|Record
options.integritystring
options.keepaliveboolean
options.methodstring
options.modeRequestMode
options.paginator|null
options.redirectRequestRedirect
options.referrerstring
options.referrerPolicyReferrerPolicy
options.signalnull|AbortSignal
options.windownull
...any
Any properties from UrlResolveOptions
Returns:Promise
fetch(url,?requestInit)
Source

Arguments:

ArgumentTypeDescription
*urlstring
requestInitRequestInit
Returns:Promise
getPaginatorClass<T>()
Source
Returns:null|
prepare(?options)
Source

Arguments:

ArgumentTypeDescription
options
An object with the properties below
options.bodynull|BodyInit
options.cacheRequestCache
options.credentialsRequestCredentials
options.headersHeadersInit|Record
options.integritystring
options.keepaliveboolean
options.methodstring
options.modeRequestMode
options.paginator|null
options.redirectRequestRedirect
options.referrerstring
options.referrerPolicyReferrerPolicy
options.signalnull|AbortSignal
options.windownull
...any
Any properties from UrlResolveOptions
Returns:
An object with these properties:
PropertyTypeDescription
*endpointEndpoint
*execute
Deprecated:
*options
*urlResolveOptionsUrlResolveOptions
resolveUrl(urlPattern,urlArgs,query,baseUrl)
Source

Arguments:

ArgumentTypeDescription
*urlPatternUrlPattern
*urlArgsRecord
*queryundefined|QueryStringParams
*baseUrlstring
Returns:string

Properties

baseUrl

Source
string

middleware

Source
(|)[]

requestInit

Source
An object with these properties:
PropertyTypeDescription
bodynull|BodyInit
cacheRequestCache
credentialsRequestCredentials
headersHeadersInit|Record
integritystring
keepaliveboolean
methodstring
modeRequestMode
paginator|null
redirectRequestRedirect
referrerstring
referrerPolicyReferrerPolicy
signalnull|AbortSignal
windownull

Static Properties

defaultConfig

Source
An object with these properties:
PropertyTypeDescription
*baseUrlstring
*getMiddleware
*middleware(|)[]
*requestInitRequestInit