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>; <TResult = ArrayBuffer>(url: string | (() => string | undefined), options?: HttpResourceOptions<TResult, ArrayBuffer> | undefined): HttpResourceRef<TResult | undefined>; <TResult = ArrayBuffer>(request: HttpResourceRequest | (() => HttpResourceRequest | undefined), options: HttpResourceOptions<TResult, ArrayBuffer> & { defaultValue: NoInfer<TResult>; }): HttpResourceRef<TResult>; <TResult = ArrayBuffer>(request: HttpResourceRequest | (() => HttpResourceRequest | undefined), options?: HttpResourceOptions<TResult, ArrayBuffer> | undefined): HttpResourceRef<TResult | undefined>; }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>; <TResult = Blob>(url: string | (() => string | undefined), options?: HttpResourceOptions<TResult, Blob> | undefined): HttpResourceRef<TResult | undefined>; <TResult = Blob>(request: HttpResourceRequest | (() => HttpResourceRequest | undefined), options: HttpResourceOptions<TResult, Blob> & { defaultValue: NoInfer<TResult>; }): HttpResourceRef<TResult>; <TResult = Blob>(request: HttpResourceRequest | (() => HttpResourceRequest | undefined), options?: HttpResourceOptions<TResult, Blob> | undefined): HttpResourceRef<TResult | undefined>; }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>; <TResult = string>(url: string | (() => string | undefined), options?: HttpResourceOptions<TResult, string> | undefined): HttpResourceRef<TResult | undefined>; <TResult = string>(request: HttpResourceRequest | (() => HttpResourceRequest | undefined), options: HttpResourceOptions<TResult, string> & { defaultValue: NoInfer<TResult>; }): HttpResourceRef<TResult>; <TResult = string>(request: HttpResourceRequest | (() => HttpResourceRequest | undefined), options?: HttpResourceOptions<TResult, string> | undefined): HttpResourceRef<TResult | undefined>; }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.