Spec-Zone.ru › Angular

httpResource

httpResource выполняет реактивный HTTP-запрос и предоставляет состояние запроса и значение ответа в виде WritableResource. По умолчанию предполагается, что сервер вернёт данные в формате JSON. Чтобы выполнить запрос, ожидающий данные другого типа, можно использовать подконструктор httpResource, например httpResource.text.

API

function httpResource<TResult = unknown>(url, options);
function httpResource<TResult = unknown>(url, options?);
function httpResource<TResult = unknown>(request, options);
function httpResource<TResult = unknown>(request, options?);

function httpResource.arrayBuffer<TResult = ArrayBuffer>(url, options);
function httpResource.arrayBuffer<TResult = ArrayBuffer>(url, options?);
function httpResource.arrayBuffer<TResult = ArrayBuffer>(request, options);
function httpResource.arrayBuffer<TResult = ArrayBuffer>(request, options?);

function httpResource.blob<TResult = Blob>(url, options);
function httpResource.blob<TResult = Blob>(url, options?);
function httpResource.blob<TResult = Blob>(request, options);
function httpResource.blob<TResult = Blob>(request, options?);

function httpResource.text<TResult = string>(url, options);
function httpResource.text<TResult = string>(url, options?);
function httpResource.text<TResult = string>(request, options);
function httpResource.text<TResult = string>(request, options?);
function httpResource<TResult = unknown>(url: (ctx: ResourceParamsContext) => string | undefined, options: HttpResourceOptions<TResult, unknown> & { defaultValue: NoInfer<TResult>; }): HttpResourceRef<TResult>;

Создаёт Resource, который получает данные с помощью HTTP GET-запроса по указанному URL.

Ресурс будет обновляться при изменении URL с помощью сигналов.

Для выполнения запросов используется HttpClient; поддерживаются перехватчики, тестирование и другие возможности API HttpClient. По умолчанию данные разбираются как JSON. Чтобы разобрать ответ иначе, используйте подфункцию httpResource, например httpResource.text().

@paramurl(ctx: ResourceParamsContext) => string | undefined
@paramoptionsHttpResourceOptions<TResult, unknown> & { defaultValue: NoInfer<TResult>; }
@returnsHttpResourceRef<TResult>
function httpResource<TResult = unknown>(url: (ctx: ResourceParamsContext) => string | undefined, options?: HttpResourceOptions<TResult, unknown> | undefined): HttpResourceRef<TResult | undefined>;

Создаёт Resource, который получает данные с помощью HTTP GET-запроса по указанному URL.

Ресурс будет обновляться при изменении URL с помощью сигналов.

Для выполнения запросов используется HttpClient; поддерживаются перехватчики, тестирование и другие возможности API HttpClient. По умолчанию данные разбираются как JSON. Чтобы разобрать ответ иначе, используйте подфункцию httpResource, например httpResource.text().

@paramurl(ctx: ResourceParamsContext) => string | undefined
@paramoptionsHttpResourceOptions<TResult, unknown> | undefined
@returnsHttpResourceRef<TResult | undefined>
function httpResource<TResult = unknown>(request: (ctx: ResourceParamsContext) => HttpResourceRequest | undefined, options: HttpResourceOptions<TResult, unknown> & { defaultValue: NoInfer<TResult>; }): HttpResourceRef<TResult>;

Создаёт Resource, который получает данные с помощью настроенного HTTP-запроса.

Ресурс будет обновляться при изменении запроса с помощью сигналов.

Для выполнения запросов используется HttpClient; поддерживаются перехватчики, тестирование и другие возможности API HttpClient. По умолчанию данные разбираются как JSON. Чтобы разобрать ответ иначе, используйте подфункцию httpResource, например httpResource.text().

@paramrequest(ctx: ResourceParamsContext) => HttpResourceRequest | undefined
@paramoptionsHttpResourceOptions<TResult, unknown> & { defaultValue: NoInfer<TResult>; }
@returnsHttpResourceRef<TResult>
function httpResource<TResult = unknown>(request: (ctx: ResourceParamsContext) => HttpResourceRequest | undefined, options?: HttpResourceOptions<TResult, unknown> | undefined): HttpResourceRef<TResult | undefined>;

Создаёт Resource, который получает данные с помощью настроенного HTTP-запроса.

Ресурс будет обновляться при изменении запроса с помощью сигналов.

Для выполнения запросов используется HttpClient; поддерживаются перехватчики, тестирование и другие возможности API HttpClient. По умолчанию данные разбираются как JSON. Чтобы разобрать ответ иначе, используйте подфункцию httpResource, например httpResource.text().

@paramrequest(ctx: ResourceParamsContext) => HttpResourceRequest | undefined
@paramoptionsHttpResourceOptions<TResult, unknown> | undefined
@returnsHttpResourceRef<TResult | undefined>
function httpResource.arrayBuffer<TResult = ArrayBuffer>(url: (ctx: ResourceParamsContext) => string | undefined, options: HttpResourceOptions<TResult, ArrayBuffer> & { defaultValue: NoInfer<TResult>; }): HttpResourceRef<TResult>;
@paramurl(ctx: ResourceParamsContext) => string | undefined
@paramoptionsHttpResourceOptions<TResult, ArrayBuffer> & { defaultValue: NoInfer<TResult>; }
@returnsHttpResourceRef<TResult>
function httpResource.arrayBuffer<TResult = ArrayBuffer>(url: (ctx: ResourceParamsContext) => string | undefined, options?: HttpResourceOptions<TResult, ArrayBuffer> | undefined): HttpResourceRef<TResult | undefined>;
@paramurl(ctx: ResourceParamsContext) => string | undefined
@paramoptionsHttpResourceOptions<TResult, ArrayBuffer> | undefined
@returnsHttpResourceRef<TResult | undefined>
function httpResource.arrayBuffer<TResult = ArrayBuffer>(request: (ctx: ResourceParamsContext) => HttpResourceRequest | undefined, options: HttpResourceOptions<TResult, ArrayBuffer> & { defaultValue: NoInfer<TResult>; }): HttpResourceRef<TResult>;
@paramrequest(ctx: ResourceParamsContext) => HttpResourceRequest | undefined
@paramoptionsHttpResourceOptions<TResult, ArrayBuffer> & { defaultValue: NoInfer<TResult>; }
@returnsHttpResourceRef<TResult>
function httpResource.arrayBuffer<TResult = ArrayBuffer>(request: (ctx: ResourceParamsContext) => HttpResourceRequest | undefined, options?: HttpResourceOptions<TResult, ArrayBuffer> | undefined): HttpResourceRef<TResult | undefined>;
@paramrequest(ctx: ResourceParamsContext) => HttpResourceRequest | undefined
@paramoptionsHttpResourceOptions<TResult, ArrayBuffer> | undefined
@returnsHttpResourceRef<TResult | undefined>
function httpResource.blob<TResult = Blob>(url: (ctx: ResourceParamsContext) => string | undefined, options: HttpResourceOptions<TResult, Blob> & { defaultValue: NoInfer<TResult>; }): HttpResourceRef<TResult>;
@paramurl(ctx: ResourceParamsContext) => string | undefined
@paramoptionsHttpResourceOptions<TResult, Blob> & { defaultValue: NoInfer<TResult>; }
@returnsHttpResourceRef<TResult>
function httpResource.blob<TResult = Blob>(url: (ctx: ResourceParamsContext) => string | undefined, options?: HttpResourceOptions<TResult, Blob> | undefined): HttpResourceRef<TResult | undefined>;
@paramurl(ctx: ResourceParamsContext) => string | undefined
@paramoptionsHttpResourceOptions<TResult, Blob> | undefined
@returnsHttpResourceRef<TResult | undefined>
function httpResource.blob<TResult = Blob>(request: (ctx: ResourceParamsContext) => HttpResourceRequest | undefined, options: HttpResourceOptions<TResult, Blob> & { defaultValue: NoInfer<TResult>; }): HttpResourceRef<TResult>;
@paramrequest(ctx: ResourceParamsContext) => HttpResourceRequest | undefined
@paramoptionsHttpResourceOptions<TResult, Blob> & { defaultValue: NoInfer<TResult>; }
@returnsHttpResourceRef<TResult>
function httpResource.blob<TResult = Blob>(request: (ctx: ResourceParamsContext) => HttpResourceRequest | undefined, options?: HttpResourceOptions<TResult, Blob> | undefined): HttpResourceRef<TResult | undefined>;
@paramrequest(ctx: ResourceParamsContext) => HttpResourceRequest | undefined
@paramoptionsHttpResourceOptions<TResult, Blob> | undefined
@returnsHttpResourceRef<TResult | undefined>
function httpResource.text<TResult = string>(url: (ctx: ResourceParamsContext) => string | undefined, options: HttpResourceOptions<TResult, string> & { defaultValue: NoInfer<TResult>; }): HttpResourceRef<TResult>;
@paramurl(ctx: ResourceParamsContext) => string | undefined
@paramoptionsHttpResourceOptions<TResult, string> & { defaultValue: NoInfer<TResult>; }
@returnsHttpResourceRef<TResult>
function httpResource.text<TResult = string>(url: (ctx: ResourceParamsContext) => string | undefined, options?: HttpResourceOptions<TResult, string> | undefined): HttpResourceRef<TResult | undefined>;
@paramurl(ctx: ResourceParamsContext) => string | undefined
@paramoptionsHttpResourceOptions<TResult, string> | undefined
@returnsHttpResourceRef<TResult | undefined>
function httpResource.text<TResult = string>(request: (ctx: ResourceParamsContext) => HttpResourceRequest | undefined, options: HttpResourceOptions<TResult, string> & { defaultValue: NoInfer<TResult>; }): HttpResourceRef<TResult>;
@paramrequest(ctx: ResourceParamsContext) => HttpResourceRequest | undefined
@paramoptionsHttpResourceOptions<TResult, string> & { defaultValue: NoInfer<TResult>; }
@returnsHttpResourceRef<TResult>
function httpResource.text<TResult = string>(request: (ctx: ResourceParamsContext) => HttpResourceRequest | undefined, options?: HttpResourceOptions<TResult, string> | undefined): HttpResourceRef<TResult | undefined>;
@paramrequest(ctx: ResourceParamsContext) => HttpResourceRequest | undefined
@paramoptionsHttpResourceOptions<TResult, string> | undefined
@returnsHttpResourceRef<TResult | undefined>

Super-powered by Google ©2010–2025.
Code licensed under an MIT-style License. Documentation licensed under CC BY 4.0.
https://angular.dev/api/common/http/httpResource

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API