[ Web Proxy ]
URL:
Viewing: https://angular.dev/api/common/http/HttpResourceRef [Back]  [Original]

HttpResourceRef Angular Skip to main content
menu
close
more_horiz
menuAPI
@angular/common/http

HttpResourceRef

interface
stablesince v22.0

A WritableResource that represents the results of a reactive HTTP request.

On this page

    arrow_upward_alt Back to the top

    API

        
          interface HttpResourceRef<T> extends WritableResource<T>, ResourceRef<T> {  readonly headers: Signal<HttpHeaders | undefined>;  readonly statusCode: Signal<number | undefined>;  readonly progress: Signal<HttpProgressEvent | undefined>;
    hasValue(this: T extends undefined ? this : never): this is HttpResourceRef<Exclude<T, undefined>>; hasValue(): boolean;
    destroy(): void; readonly override value: WritableSignal<T>; override set(value: T): void; override update(updater: (value: T) => T): void; override asReadonly(): Resource<T>; override reload(): boolean; readonly override status: Signal<ResourceStatus>; readonly override error: Signal<Error | undefined>; readonly override isLoading: Signal<boolean>; readonly override snapshot: Signal<ResourceSnapshot<T>>;}

    headers

    Signal<HttpHeaders | undefined>

    Signal of the response headers, when available.

    statusCode

    Signal<number | undefined>

    Signal of the response status code, when available.

    progress

    Signal<HttpProgressEvent | undefined>

    Signal of the latest progress update, if the request was made with reportProgress: true.

    hasValue

    2 overloads
    @paramthisT extends undefined ? this : never
    @returnsthis is HttpResourceRef<Exclude<T, undefined>>
    @returnsboolean

    destroy

    void
    @returnsvoid

    value

    WritableSignal<T>

    set

    void

    Convenience wrapper for value.set.

    @paramvalueT
    @returnsvoid

    update

    void

    Convenience wrapper for value.update.

    @paramupdater(value: T) => T
    @returnsvoid

    asReadonly

    Resource<T>
    @returnsResource<T>

    reload

    boolean

    Instructs the resource to re-load any asynchronous dependency it may have.

    Note that the resource will not enter its reloading state until the actual backend request is made.

    @returnsboolean

    true if a reload was initiated, false if a reload was unnecessary or unsupported

    status

    Signal<ResourceStatus>

    The current status of the Resource, which describes what the resource is currently doing and what can be expected of its value.

    error

    Signal<Error | undefined>

    When in the error state, this returns the last known error from the Resource.

    isLoading

    Signal<boolean>

    Whether this resource is loading a new value (or reloading the existing one).

    snapshot

    Signal<ResourceSnapshot<T>>

    The current state of this resource, represented as a ResourceSnapshot.

    Description

    A WritableResource that represents the results of a reactive HTTP request.

    HttpResources are backed by HttpClient, including support for interceptors, testing, and the other features of the HttpClient API.

    Jump to details

    Web Proxy Viewer  |  New URL  |  Original Page