HttpClient
执行 HTTP 请求。
Perform HTTP requests.
class HttpClient {
request(first: string | HttpRequest<any>, url?: string, options: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: HttpObserve; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "arraybuffer" | ... 2 more ... | "json"; withCredentials?: boolean; } = {}): Observable<any>
delete(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: HttpObserve; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "arraybuffer" | "blob" | "text" | "json"; withCredentials?: boolean; } = {}): Observable<any>
get(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: HttpObserve; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "arraybuffer" | "blob" | "text" | "json"; withCredentials?: boolean; } = {}): Observable<any>
head(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: HttpObserve; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "arraybuffer" | "blob" | "text" | "json"; withCredentials?: boolean; } = {}): Observable<any>
jsonp<T>(url: string, callbackParam: string): Observable<T>
options(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: HttpObserve; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "arraybuffer" | "blob" | "text" | "json"; withCredentials?: boolean; } = {}): Observable<any>
patch(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: HttpObserve; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "arraybuffer" | "blob" | "text" | "json"; withCredentials?: boolean; } = {}): Observable<any>
post(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: HttpObserve; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "arraybuffer" | "blob" | "text" | "json"; withCredentials?: boolean; } = {}): Observable<any>
put(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: HttpObserve; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "arraybuffer" | "blob" | "text" | "json"; withCredentials?: boolean; } = {}): Observable<any>
}
说明
HttpClient
是一个可供注入的类,具有一些用来执行 HTTP 请求的方法。 每个请求方法都有多重签名,并根据签名返回不同的数据类型(主要取决于 observe
和 responseType
的值)。
HttpClient
is available as an injectable class, with methods to perform HTTP requests. Each request method has multiple signatures, and the return type varies according to which signature is called (mainly the values of observe
and responseType
).
方法
为一个特定的 HTTP 请求构造一个 Constructs an | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
17 个重载形式...显示所有 隐藏所有 expand_moreOverload #1发送指定的 Send the given
参数
返回值
Overload #2构造一个请求,这个请求会把 body 解释为 Construct a request which interprets the body as an
参数
返回值一个由
Overload #3构造一个请求,这个请求会把 body 解释为 Construct a request which interprets the body as a
参数
返回值一个由 Overload #4构造一个请求,这个请求会把 body 解释为文本,并返回它。 Construct a request which interprets the body as text and returns it.
参数
返回值一个由
Overload #5构造一个请求,这个请求会把 body 解释为 Construct a request which interprets the body as an
参数
返回值一个由该请求的所有
Overload #6构造一个请求,这个请求会把 body 解释为 Construct a request which interprets the body as an
参数
返回值一个由该请求的所有
Overload #7构造一个请求,这个请求会把 body 解释为文本,并返回完整的事件流。 Construct a request which interprets the body as text and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #8构造一个请求,这个请求会把 body 解释为 JSON ,并返回完整的事件流。 Construct a request which interprets the body as JSON and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #9构造一个请求,这个请求会把 body 解释为 JSON ,并返回完整的事件流。 Construct a request which interprets the body as JSON and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #10构造一个请求,这个请求会把 body 解释为 Construct a request which interprets the body as an
参数
返回值一个由该请求的
Overload #11构造一个请求,这个请求会把 body 解释为 Construct a request which interprets the body as a
参数
返回值一个由该请求的
Overload #12构造一个请求,这个请求会把 body 解释为文本,并返回完整的响应体。 Construct a request which interprets the body as text and returns the full response.
参数
返回值一个由该请求的
Overload #13构造一个请求,这个请求会把 body 解释为 JSON ,并返回完整的响应体。 Construct a request which interprets the body as JSON and returns the full response.
参数
返回值一个由该请求的
Overload #14构造一个请求,这个请求会把 body 解释为 JSON ,并返回完整的响应体。 Construct a request which interprets the body as JSON and returns the full response.
参数
返回值一个由该请求的
Overload #15构造一个请求,这个请求会把 body 解释为 JSON ,并返回它。 Construct a request which interprets the body as JSON and returns it.
参数
返回值一个由该请求的
Overload #16构造一个请求,这个请求会把 body 解释为 JSON ,并返回它。 Construct a request which interprets the body as JSON and returns it.
参数
返回值一个由该请求的
Overload #17以某种方式构造请求,其响应类型和所请求的 Construct a request in a manner where response type and requested
参数
返回值所请求的任意
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
该方法有两种调用方式。或者直接把一个 This method can be called in one of two ways. Either an 如果直接传入 If a 如果是通过提供 URL 的方式构建的,配置项将决定 If a request is instead built by providing a URL, the options object determines the return type of
The
The |
构造一个 Constructs an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
15 个重载形式...显示所有 隐藏所有 expand_moreOverload #1构造一个 Construct a DELETE request which interprets the body as an
参数
返回值一个由
Overload #2构造一个 Construct a DELETE request which interprets the body as a
参数
返回值一个由 Overload #3构造一个 Construct a DELETE request which interprets the body as text and returns it.
参数
返回值一个由
Overload #4构造一个 Construct a DELETE request which interprets the body as an
参数
返回值一个由该请求的所有
Overload #5构造一个 Construct a DELETE request which interprets the body as a
参数
返回值一个由该请求的所有
Overload #6构造一个 Construct a DELETE request which interprets the body as text and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #7构造一个 Construct a DELETE request which interprets the body as JSON and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #8构造一个 Construct a DELETE request which interprets the body as JSON and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #9构造一个 Construct a DELETE request which interprets the body as an
参数
返回值一个由该请求的
Overload #10构造一个 Construct a DELETE request which interprets the body as a
参数
返回值一个由该请求的
Overload #11构造一个 Construct a DELETE request which interprets the body as text and returns the full response.
参数
返回值一个由该请求的
Overload #12构造一个 Construct a DELETE request which interprets the body as JSON and returns the full response.
参数
返回值一个由该请求的
Overload #13构造一个 Construct a DELETE request which interprets the body as JSON and returns the full response.
参数
返回值一个由该请求的
Overload #14构造一个 Construct a DELETE request which interprets the body as JSON and returns it.
参数
返回值一个由
Overload #15构造一个 Construct a DELETE request which interprets the body as JSON and returns it.
参数
返回值一个由
|
构造一个 Constructs an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
15 个重载形式...显示所有 隐藏所有 expand_moreOverload #1构造一个 Construct a GET request which interprets the body as an
参数
返回值一个由
Overload #2构造一个 Construct a GET request which interprets the body as a
参数
返回值一个由 Overload #3构造一个 Construct a GET request which interprets the body as text and returns it.
参数
返回值一个由
Overload #4构造一个 Construct a GET request which interprets the body as an
参数
返回值一个由该请求的所有
Overload #5构造一个 Construct a GET request which interprets the body as a
参数
返回值一个由该请求的所有
Overload #6构造一个 Construct a GET request which interprets the body as text and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #7构造一个 Construct a GET request which interprets the body as JSON and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #8构造一个 Construct a GET request which interprets the body as JSON and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #9构造一个 Construct a GET request which interprets the body as an
参数
返回值一个由该请求的
Overload #10构造一个 Construct a GET request which interprets the body as a
参数
返回值一个由该请求的
Overload #11构造一个 Construct a GET request which interprets the body as text and returns the full response.
参数
返回值一个由该请求的
Overload #12构造一个 Construct a GET request which interprets the body as JSON and returns the full response.
参数
返回值一个由该请求的
Overload #13构造一个 Construct a GET request which interprets the body as JSON and returns the full response.
参数
返回值一个由该请求的
Overload #14构造一个 Construct a GET request which interprets the body as JSON and returns it.
参数
返回值一个由
Overload #15构造一个 Construct a GET request which interprets the body as JSON and returns it.
参数
返回值一个由
|
构造一个 Constructs an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
15 个重载形式...显示所有 隐藏所有 expand_moreOverload #1构造一个 Construct a HEAD request which interprets the body as an
参数
返回值一个由
Overload #2
参数
返回值
Overload #3构造一个 Construct a HEAD request which interprets the body as text and returns it.
参数
返回值一个由
Overload #4构造一个 Construct a HEAD request which interprets the body as an
参数
返回值一个由该请求的所有
Overload #5构造一个 Construct a HEAD request which interprets the body as a
参数
返回值一个由该请求的所有
Overload #6构造一个 Construct a HEAD request which interprets the body as text and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #7构造一个 Construct a HEAD request which interprets the body as JSON and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #8构造一个 Construct a HEAD request which interprets the body as JSON and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #9构造一个 Construct a HEAD request which interprets the body as an
参数
返回值一个由该请求的
Overload #10构造一个 Construct a HEAD request which interprets the body as a
参数
返回值一个由该请求的
Overload #11构造一个 Construct a HEAD request which interprets the body as text and returns the full response.
参数
返回值一个由该请求的
Overload #12构造一个 Construct a HEAD request which interprets the body as JSON and returns the full response.
参数
返回值一个由该请求的
Overload #13构造一个 Construct a HEAD request which interprets the body as JSON and returns the full response.
参数
返回值一个由该请求的
Overload #14构造一个 Construct a HEAD request which interprets the body as JSON and returns it.
参数
返回值一个由
Overload #15构造一个 Construct a HEAD request which interprets the body as JSON and returns it.
参数
返回值一个由
|
构造一个 Constructs an | ||||||
使用指定的 URL 和回调函数名构造一个 JSONP 请求。 Construct a JSONP request for the given URL and name of the callback parameter.
参数
返回值一个
| ||||||
必须安装一个合适的拦截器(比如借助 A suitable interceptor must be installed (e.g. via the |
构造一个 Constructs an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
15 个重载形式...显示所有 隐藏所有 expand_moreOverload #1构造一个 Make an OPTIONS request which interprets the body as an
参数
返回值一个由
Overload #2构造一个 Construct an OPTIONS request which interprets the body as a
参数
返回值一个由 Overload #3构造一个 Construct an OPTIONS request which interprets the body as text and returns it.
参数
返回值一个由
Overload #4构造一个 Construct an OPTIONS request which interprets the body as an
参数
返回值一个由该请求的所有
Overload #5构造一个 Construct an OPTIONS request which interprets the body as a
参数
返回值一个由该请求的所有
Overload #6构造一个 Construct an OPTIONS request which interprets the body as text and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #7构造一个 Construct an OPTIONS request which interprets the body as JSON and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #8构造一个 Construct an OPTIONS request which interprets the body as JSON and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #9构造一个 Construct an OPTIONS request which interprets the body as an
参数
返回值一个由该请求的
Overload #10构造一个 Construct an OPTIONS request which interprets the body as a
参数
返回值一个由该请求的
Overload #11构造一个 Construct an OPTIONS request which interprets the body as text and returns the full response.
参数
返回值一个由该请求的
Overload #12构造一个 Construct an OPTIONS request which interprets the body as JSON and returns the full response.
参数
返回值一个由该请求的
Overload #13构造一个 Construct an OPTIONS request which interprets the body as JSON and returns the full response.
参数
返回值一个由该请求的
Overload #14构造一个 Construct an OPTIONS request which interprets the body as JSON and returns it.
参数
返回值一个由
Overload #15构造一个 Construct an OPTIONS request which interprets the body as JSON and returns it.
参数
返回值一个由
|
构造一个 Constructs an | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
15 个重载形式...显示所有 隐藏所有 expand_moreOverload #1构造一个 Construct a PATCH request which interprets the body as an
参数
返回值一个由
Overload #2构造一个 Construct a PATCH request which interprets the body as a
参数
返回值一个由 Overload #3构造一个 Construct a PATCH request which interprets the body as text and returns it.
参数
返回值一个由
Overload #4构造一个 Construct a PATCH request which interprets the body as an
参数
返回值一个由该请求的所有
Overload #5构造一个 Construct a PATCH request which interprets the body as a
参数
返回值一个由该请求的所有
Overload #6构造一个 Construct a PATCH request which interprets the body as text and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #7构造一个 Construct a PATCH request which interprets the body as JSON and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #8构造一个 Construct a PATCH request which interprets the body as JSON and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #9构造一个 Construct a PATCH request which interprets the body as an
参数
返回值一个由该请求的
Overload #10构造一个 Construct a PATCH request which interprets the body as a
参数
返回值一个由该请求的
Overload #11构造一个 Construct a PATCH request which interprets the body as text and returns the full response.
参数
返回值一个由该请求的
Overload #12构造一个 Construct a PATCH request which interprets the body as JSON and returns the full response.
参数
返回值一个由该请求的
Overload #13构造一个 Construct a PATCH request which interprets the body as JSON and returns the full response.
参数
返回值一个由该请求的
Overload #14构造一个 Construct a PATCH request which interprets the body as JSON and returns it.
参数
返回值一个由
Overload #15构造一个 Construct a PATCH request which interprets the body as JSON and returns it.
参数
返回值一个由
|
构造一个 Constructs an | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
15 个重载形式...显示所有 隐藏所有 expand_moreOverload #1构造一个 Construct a POST request which interprets the body as an
参数
返回值一个由
Overload #2构造一个 Construct a POST request which interprets the body as a
参数
返回值一个由 Overload #3构造一个 Construct a POST request which interprets the body as text and returns it.
参数
返回值一个由
Overload #4构造一个 Construct a POST request which interprets the body as an
参数
返回值一个由该请求的所有
Overload #5构造一个 Construct a POST request which interprets the body as a
参数
返回值一个由该请求的所有
Overload #6构造一个 Construct a POST request which interprets the body as text and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #7构造一个 Construct a POST request which interprets the body as JSON and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #8构造一个 Construct a POST request which interprets the body as JSON and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #9构造一个 Construct a POST request which interprets the body as an
参数
返回值一个由该请求的
Overload #10构造一个 Construct a POST request which interprets the body as a
参数
返回值一个由该请求的
Overload #11构造一个 Construct a POST request which interprets the body as text and returns the full response.
参数
返回值一个由该请求的
Overload #12构造一个 Construct a POST request which interprets the body as JSON and returns the full response.
参数
返回值一个由该请求的
Overload #13构造一个 Construct a POST request which interprets the body as JSON and returns the full response.
参数
返回值一个由该请求的
Overload #14构造一个 Construct a POST request which interprets the body as JSON and returns it.
参数
返回值一个由
Overload #15构造一个 Construct a POST request which interprets the body as JSON and returns it.
参数
返回值一个由
|
构造一个 Constructs an | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
15 个重载形式...显示所有 隐藏所有 expand_moreOverload #1构造一个 Construct a PUT request which interprets the body as an
参数
返回值一个由
Overload #2构造一个 Construct a PUT request which interprets the body as a
参数
返回值一个由 Overload #3构造一个 Construct a PUT request which interprets the body as text and returns it.
参数
返回值一个由
Overload #4构造一个 Construct a PUT request which interprets the body as an
参数
返回值一个由该请求的所有
Overload #5构造一个 Construct a PUT request which interprets the body as a
参数
返回值一个由该请求的所有
Overload #6构造一个 Construct a PUT request which interprets the body as text and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #7构造一个 Construct a PUT request which interprets the body as JSON and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #8构造一个 Construct a PUT request which interprets the body as JSON and returns the full event stream.
参数
返回值一个由该请求的所有
Overload #9构造一个 Construct a PUT request which interprets the body as an
参数
返回值一个由该请求的
Overload #10构造一个 Construct a PUT request which interprets the body as a
参数
返回值一个由该请求的
Overload #11构造一个 Construct a PUT request which interprets the body as text and returns the full response.
参数
返回值一个由该请求的
Overload #12构造一个 Construct a PUT request which interprets the body as JSON and returns the full response.
参数
返回值一个由该请求的
Overload #13构造一个 Construct a PUT request which interprets the body as JSON and returns the full response.
参数
返回值一个由该请求的
Overload #14构造一个 Construct a PUT request which interprets the body as JSON and returns it.
参数
返回值一个由
Overload #15构造一个 Construct a PUT request which interprets the body as JSON and returns it.
参数
返回值一个由
|