Response

Response

Experimental Class

Class Overview

class Response extends Body {
  constructor(responseOptions: ResponseOptions)
  
  
  type : ResponseType
  ok : boolean
  url : string
  status : number
  statusText : string
  bytesLoaded : number
  totalBytes : number
  headers : Headers
  toString() : string
}

Class Description

Creates Response instances from provided values.

Though this object isn't usually instantiated by end-users, it is the primary object interacted with when it comes time to add data to a view.

Example

http.request('my-friends.txt').subscribe(response => this.friends = response.text());

The Response's interface is inspired by the Response constructor defined in the Fetch Spec, but is considered a static value whose body can be accessed many times. There are other differences in the implementation, but this is the most significant.

Constructor

constructor(responseOptions: ResponseOptions)

Class Details

type : ResponseType

One of "basic", "cors", "default", "error", or "opaque".

Defaults to "default".

ok : boolean

True if the response's status is within 200-299

url : string

URL of response.

Defaults to empty string.

status : number

Status code returned by server.

Defaults to 200.

statusText : string

Text representing the corresponding reason phrase to the status, as defined in ietf rfc 2616 section 6.1.1

Defaults to "OK"

bytesLoaded : number

Non-standard property

Denotes how many of the response body's bytes have been loaded, for example if the response is the result of a progress event.

totalBytes : number

Non-standard property

Denotes how many bytes are expected in the final response body.

headers : Headers

Headers object based on the Headers class in the Fetch Spec.

toString() : string

exported from http-index, defined in http/src/static_response.ts

© 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/docs/ts/latest/api/http/index/Response-class.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部