Type for the httpRequest
top-level function, which includes the call signatures for the JSON-
based httpRequest
as well as sub-functions for ArrayBuffer
, Blob
, and string
type
requests.
API
interface HttpResourceFn {
<TResult = unknown>(url: string | (() => string | undefined), options: HttpResourceOptions<TResult, unknown> & { defaultValue: NoInfer<TResult>; }): HttpResourceRef<TResult>; <TResult = unknown>(url: string | (() => string | undefined), options?: HttpResourceOptions<TResult, unknown> | undefined): HttpResourceRef<TResult | undefined>; <TResult = unknown>(request: HttpResourceRequest | (() => HttpResourceRequest | undefined), options: HttpResourceOptions<TResult, unknown> & { defaultValue: NoInfer<TResult>; }): HttpResourceRef<TResult>; <TResult = unknown>(request: HttpResourceRequest | (() => HttpResourceRequest | undefined), options?: HttpResourceOptions<TResult, unknown> | undefined): HttpResourceRef<TResult | undefined>;}
HttpResourceRef<TResult>
Create a Resource
that fetches data with an HTTP GET request to the given URL.
If a reactive function is passed for the URL, the resource will update when the URL changes via signals.
Uses HttpClient
to make requests and supports interceptors, testing, and the other features
of the HttpClient
API. Data is parsed as JSON by default - use a sub-function of
httpResource
, such as httpResource.text()
, to parse the response differently.
string | (() => string | undefined)
HttpResourceRef<TResult>
HttpResourceRef<TResult | undefined>
Create a Resource
that fetches data with an HTTP GET request to the given URL.
If a reactive function is passed for the URL, the resource will update when the URL changes via signals.
Uses HttpClient
to make requests and supports interceptors, testing, and the other features
of the HttpClient
API. Data is parsed as JSON by default - use a sub-function of
httpResource
, such as httpResource.text()
, to parse the response differently.
string | (() => string | undefined)
HttpResourceRef<TResult | undefined>
HttpResourceRef<TResult>
Create a Resource
that fetches data with the configured HTTP request.
If a reactive function is passed for the request, the resource will update when the request changes via signals.
Uses HttpClient
to make requests and supports interceptors, testing, and the other features
of the HttpClient
API. Data is parsed as JSON by default - use a sub-function of
httpResource
, such as httpResource.text()
, to parse the response differently.
HttpResourceRef<TResult>
HttpResourceRef<TResult | undefined>
Create a Resource
that fetches data with the configured HTTP request.
If a reactive function is passed for the request, the resource will update when the request changes via signals.
Uses HttpClient
to make requests and supports interceptors, testing, and the other features
of the HttpClient
API. Data is parsed as JSON by default - use a sub-function of
httpResource
, such as httpResource.text()
, to parse the response differently.
HttpResourceRef<TResult | undefined>
arrayBuffer
{ <TResult = ArrayBuffer>(url: string | (() => string | undefined), options: HttpResourceOptions<TResult, ArrayBuffer> & { defaultValue: NoInfer<TResult>; }): HttpResourceRef<...>; <TResult = ArrayBuffer>(url: string | (() => string | undefined), options?: HttpResourceOptions<...> | undefined): HttpResourceRef<...>;...
Create a Resource
that fetches data with the configured HTTP request.
If a reactive function is passed for the URL or request, the resource will update when the URL or request changes via signals.
Uses HttpClient
to make requests and supports interceptors, testing, and the other features
of the HttpClient
API. Data is parsed into an ArrayBuffer
.
blob
{ <TResult = Blob>(url: string | (() => string | undefined), options: HttpResourceOptions<TResult, Blob> & { defaultValue: NoInfer<TResult>; }): HttpResourceRef<...>; <TResult = Blob>(url: string | (() => string | undefined), options?: HttpResourceOptions<...> | undefined): HttpResourceRef<...>; <TResult = Blob>(req...
Create a Resource
that fetches data with the configured HTTP request.
If a reactive function is passed for the URL or request, the resource will update when the URL or request changes via signals.
Uses HttpClient
to make requests and supports interceptors, testing, and the other features
of the HttpClient
API. Data is parsed into a Blob
.
text
{ <TResult = string>(url: string | (() => string | undefined), options: HttpResourceOptions<TResult, string> & { defaultValue: NoInfer<TResult>; }): HttpResourceRef<...>; <TResult = string>(url: string | (() => string | undefined), options?: HttpResourceOptions<...> | undefined): HttpResourceRef<...>; <TResult = str...
Create a Resource
that fetches data with the configured HTTP request.
If a reactive function is passed for the URL or request, the resource will update when the URL or request changes via signals.
Uses HttpClient
to make requests and supports interceptors, testing, and the other features
of the HttpClient
API. Data is parsed as a string
.