Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
This site is no longer updated.Head to Angular.devHome
/

This is the archived documentation for Angular v17. Please visit angular.dev to see this page for the current version of Angular.

HttpResponseBase

Base class for both HttpResponse and HttpHeaderResponse.

      
      abstract class HttpResponseBase {
  constructor(init: { headers?: HttpHeaders; status?: number; statusText?: string; url?: string; }, defaultStatus: number = HttpStatusCode.Ok, defaultStatusText: string = 'OK')
  headers: HttpHeaders
  status: number
  statusText: string
  url: string | null
  ok: boolean
  type: HttpEventType.Response | HttpEventType.ResponseHeader
}
    

Constructor

Super-constructor for all responses.

      
      constructor(init: { headers?: HttpHeaders; status?: number; statusText?: string; url?: string; }, defaultStatus: number = HttpStatusCode.Ok, defaultStatusText: string = 'OK')
    
Parameters
init object
defaultStatus number

Optional. Default is HttpStatusCode.Ok.

defaultStatusText string

Optional. Default is 'OK'.

The single parameter accepted is an initialization hash. Any properties of the response passed there will override the default values.

Properties

Property Description
headers: HttpHeaders Read-Only

All response headers.

status: number Read-Only

Response status code.

statusText: string Read-Only

Textual description of response status code, defaults to OK.

Do not depend on this.

url: string | null Read-Only

URL of the resource retrieved, or null if not available.

ok: boolean Read-Only

Whether the status code falls in the 2xx range.

type: HttpEventType.Response | HttpEventType.ResponseHeader Read-Only

Type of the response, narrowed to either the full response or the header.