W3cubDocs

/Angular 10

HttpClient

class

Performs HTTP requests. This service is available as an injectable class, with methods to perform HTTP requests. Each request method has multiple signatures, and the return type varies based on the signature that is called (mainly the values of observe and responseType).

See more...

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" | ... 2 more ... | "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" | ... 2 more ... | "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" | ... 2 more ... | "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" | ... 2 more ... | "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" | ... 2 more ... | "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" | ... 2 more ... | "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" | ... 2 more ... | "json"; withCredentials?: boolean; } = {}): Observable<any>
}

See also

Description

Note that the responseType options value is a String that identifies the single data type of the response. A single overload version of the method handles each response type. The value of responseType cannot be a union, as the combined signature could imply.

Methods

Constructs an observable for a generic HTTP request that, when subscribed, fires the request through the chain of registered interceptors and on to the server.

17 overloads...

Show All Hide All
Overload #1

Sends an HTTPRequest and returns a stream of HTTPEvents.

request<R>(req: HttpRequest<any>): Observable<HttpEvent<R>>

Parameters
req HttpRequest
Returns

Observable<HttpEvent<R>>: An Observable of the response, with the response body as a stream of HTTPEvents.

Overload #2

Constructs a request that interprets the body as an ArrayBuffer and returns the response in an ArrayBuffer.

request(method: string, url: string, options: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<ArrayBuffer>

Parameters
method string

The HTTP method.

url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<ArrayBuffer>: An Observable of the response, with the response body as an ArrayBuffer.

Overload #3

Constructs a request that interprets the body as a blob and returns the response as a blob.

request(method: string, url: string, options: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<Blob>

Parameters
method string

The HTTP method.

url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<Blob>: An Observable of the response, with the response body of type Blob.

Overload #4

Constructs a request that interprets the body as a text string and returns a string value.

request(method: string, url: string, options: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<string>

Parameters
method string

The HTTP method.

url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<string>: An Observable of the response, with the response body of type string.

Overload #5

Constructs a request that interprets the body as an ArrayBuffer and returns the the full event stream.

request(method: string, url: string, options: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; params?: HttpParams | { [param: string]: string | string[]; }; observe: "events"; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<HttpEvent<ArrayBuffer>>

Parameters
method string

The HTTP method.

url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<ArrayBuffer>>: An Observable of the response, with the response body as an array of HTTPEvents for the request.

Overload #6

Constructs a request that interprets the body as a Blob and returns the full event stream.

request(method: string, url: string, options: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<HttpEvent<Blob>>

Parameters
method string

The HTTP method.

url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<Blob>>: An Observable of of all HttpEvents for the request, with the response body of type Blob.

Overload #7

Constructs a request which interprets the body as a text string and returns the full event stream.

request(method: string, url: string, options: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<HttpEvent<string>>

Parameters
method string

The HTTP method.

url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<string>>: An Observable of all HttpEvents for the reques, with the response body of type string.

Overload #8

Constructs a request which interprets the body as a JSON object and returns the full event stream.

request(method: string, url: string, options: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; reportProgress?: boolean; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpEvent<any>>

Parameters
method string

The HTTP method.

url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<any>>: An Observable of all HttpEvents for the request, with the response body of type Object.

Overload #9

Constructs a request which interprets the body as a JSON object and returns the full event stream.

request<R>(method: string, url: string, options: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; reportProgress?: boolean; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpEvent<R>>

Parameters
method string

The HTTP method.

url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<R>>: An Observable of all HttpEvents for the request, with the response body of type R.

Overload #10

Constructs a request which interprets the body as an ArrayBuffer and returns the full HTTPResponse.

request(method: string, url: string, options: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<HttpResponse<ArrayBuffer>>

Parameters
method string

The HTTP method.

url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<ArrayBuffer>>: An Observable of the HTTPResponse, with the response body as an ArrayBuffer.

Overload #11

Constructs a request which interprets the body as a Blob and returns the full HTTPResponse.

request(method: string, url: string, options: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<HttpResponse<Blob>>

Parameters
method string

The HTTP method.

url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<Blob>>: An Observable of the HTTPResponse, with the response body of type Blob.

Overload #12

Constructs a request which interprets the body as a text stream and returns the full HTTPResponse.

request(method: string, url: string, options: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<HttpResponse<string>>

Parameters
method string

The HTTP method.

url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<string>>: An Observable of the HTTP response, with the response body of type string.

Overload #13

Constructs a request which interprets the body as a JSON object and returns the full HTTPResponse.

request(method: string, url: string, options: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; reportProgress?: boolean; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpResponse<Object>>

Parameters
method string

The HTTP method.

url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<Object>>: An Observable of the full HTTPResponse, with the response body of type Object.

Overload #14

Constructs a request which interprets the body as a JSON object and returns the full HTTPResponse with the response body in the requested type.

request<R>(method: string, url: string, options: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; reportProgress?: boolean; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpResponse<R>>

Parameters
method string

The HTTP method.

url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<R>>: An Observable of the full HTTPResponse, with the response body of type R.

Overload #15

Constructs a request which interprets the body as a JSON object and returns the full HTTPResponse as a JSON object.

request(method: string, url: string, options?: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; responseType?: "json"; reportProgress?: boolean; withCredentials?: boolean; }): Observable<Object>

Parameters
method string

The HTTP method.

url string

The endpoint URL.

options object

The HTTP options to send with the request.

Optional. Default is undefined.

Returns

Observable<Object>: An Observable of the HTTPResponse, with the response body of type Object.

Overload #16

Constructs a request which interprets the body as a JSON object with the response body of the requested type.

request<R>(method: string, url: string, options?: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; responseType?: "json"; reportProgress?: boolean; withCredentials?: boolean; }): Observable<R>

Parameters
method string

The HTTP method.

url string

The endpoint URL.

options object

The HTTP options to send with the request.

Optional. Default is undefined.

Returns

Observable<R>: An Observable of the HTTPResponse, with the response body of type R.

Overload #17

Constructs a request where response type and requested observable are not known statically.

request(method: string, url: string, options?: { body?: any; headers?: HttpHeaders | { [header: string]: string | string[]; }; params?: HttpParams | { [param: string]: string | string[]; }; observe?: HttpObserve; reportProgress?: boolean; responseType?: "arraybuffer" | ... 2 more ... | "json"; withCredentials?: boolean; }): Observable<any>

Parameters
method string

The HTTP method.

url string

The endpoint URL.

options object

The HTTP options to send with the request.

Optional. Default is undefined.

Returns

Observable<any>: An Observable of the reuested response, wuth body of type any.

You can pass an HttpRequest directly as the only parameter. In this case, the call returns an observable of the raw HttpEvent stream.

Alternatively you can pass an HTTP method as the first parameter, a URL string as the second, and an options hash containing the request body as the third. See addBody(). In this case, the specified responseType and observe options determine the type of returned observable.

  • The responseType value determines how a successful response body is parsed.
  • If responseType is the default json, you can pass a type interface for the resulting object as a type parameter to the call.

The observe value determines the return type, according to what you are interested in observing.

  • An observe value of events returns an observable of the raw HttpEvent stream, including progress events by default.
  • An observe value of response returns an observable of HttpResponse<T>, where the T parameter depends on the responseType and any optionally provided type parameter.
  • An observe value of body returns an observable of <T> with the same T body type.

Constructs an observable that, when subscribed, causes the configured DELETE request to execute on the server. See the individual overloads for details on the return type.

15 overloads...

Show All Hide All
Overload #1

Constructs a DELETE request that interprets the body as an ArrayBuffer and returns the response as an ArrayBuffer.

delete(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<ArrayBuffer>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<ArrayBuffer>: An Observable of the response body as an ArrayBuffer.

Overload #2

Constructs a DELETE request that interprets the body as a Blob and returns the response as a Blob.

delete(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<Blob>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<Blob>: An Observable of the response body as a Blob.

Overload #3

Constructs a DELETE request that interprets the body as a text string and returns a string.

delete(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<string>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<string>: An Observable of the response, with the response body of type string.

Overload #4

Constructs a DELETE request that interprets the body as an ArrayBuffer and returns the full event stream.

delete(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<HttpEvent<ArrayBuffer>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<ArrayBuffer>>: An Observable of all HTTPEvents for the request, with response body as an ArrayBuffer.

Overload #5

Constructs a DELETE request that interprets the body as a Blob and returns the full event stream.

delete(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<HttpEvent<Blob>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<Blob>>: An Observable of all the HTTPEvents for the request, with the response body as a Blob.

Overload #6

Constructs a DELETE request that interprets the body as a text string and returns the full event stream.

delete(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<HttpEvent<string>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<string>>: An Observable of all HTTPEvents for the request, with the response body of type string.

Overload #7

Constructs a DELETE request that interprets the body as a JSON object and returns the full event stream.

delete(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpEvent<Object>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<Object>>: An Observable of all HTTPEvents for the request, with response body of type Object.

Overload #8

Constructs a DELETErequest that interprets the body as a JSON object and returns the full event stream.

delete<T>(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpEvent<T>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<T>>: An Observable of all the HTTPEvents for the request, with a response body in the requested type.

Overload #9

Constructs a DELETE request that interprets the body as an ArrayBuffer and returns the full HTTPResponse.

delete(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<HttpResponse<ArrayBuffer>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<ArrayBuffer>>: An Observable of the full HTTPResponse, with the response body as an ArrayBuffer.

Overload #10

Constructs a DELETE request that interprets the body as a Blob and returns the full HTTPResponse.

delete(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<HttpResponse<Blob>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<Blob>>: An Observable of the HTTPResponse, with the response body of type Blob.

Overload #11

Constructs a DELETE request that interprets the body as a text stream and returns the full HTTPResponse.

delete(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<HttpResponse<string>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<string>>: An Observable of the full HTTPResponse, with the response body of type string.

Overload #12

Constructs a DELETE request the interprets the body as a JSON object and returns the full HTTPResponse.

delete(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpResponse<Object>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<Object>>: An Observable of the HTTPResponse, with the response body of type Object.

Overload #13

Constructs a DELETE request that interprets the body as a JSON object and returns the full HTTPResponse.

delete<T>(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpResponse<T>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<T>>: An Observable of the HTTPResponse, with the response body of the requested type.

Overload #14

Constructs a DELETE request that interprets the body as a JSON object and returns the response body as a JSON object.

delete(url: string, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<Object>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Optional. Default is undefined.

Returns

Observable<Object>: An Observable of the response, with the response body of type Object.

Overload #15

Constructs a DELETE request that interprets the body as a JSON object and returns the response in a given type.

delete<T>(url: string, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<T>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Optional. Default is undefined.

Returns

Observable<T>: An Observable of the HTTPResponse, with response body in the requested type.

Constructs an observable that, when subscribed, causes the configured GET request to execute on the server. See the individual overloads for details on the return type.

15 overloads...

Show All Hide All
Overload #1

Constructs a GET request that interprets the body as an ArrayBuffer and returns the response in an ArrayBuffer.

get(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<ArrayBuffer>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<ArrayBuffer>: An Observable of the response, with the response body as an ArrayBuffer.

Overload #2

Constructs a GET request that interprets the body as a Blob and returns the response as a Blob.

get(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<Blob>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<Blob>: An Observable of the response, with the response body as a Blob.

Overload #3

Constructs a GET request that interprets the body as a text string and returns the response as a string value.

get(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<string>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<string>: An Observable of the response, with the response body of type string.

Overload #4

Constructs a GET request that interprets the body as an ArrayBuffer and returns the full event stream.

get(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<HttpEvent<ArrayBuffer>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<ArrayBuffer>>: An Observable of all HttpEvents for the request, with the response body as an ArrayBuffer.

Overload #5

Constructs a GET request that interprets the body as a Blob and returns the full event stream.

get(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<HttpEvent<Blob>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<Blob>>: An Observable of the response, with the response body as a Blob.

Overload #6

Constructs a GET request that interprets the body as a text string and returns the full event stream.

get(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<HttpEvent<string>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<string>>: An Observable of the response, with the response body of type string.

Overload #7

Constructs a GET request that interprets the body as a JSON object and returns the full event stream.

get(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpEvent<Object>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<Object>>: An Observable of the response, with the response body of type Object.

Overload #8

Constructs a GET request that interprets the body as a JSON object and returns the full event stream.

get<T>(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpEvent<T>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<T>>: An Observable of the response, with a response body in the requested type.

Overload #9

Constructs a GET request that interprets the body as an ArrayBuffer and returns the full HTTPResponse.

get(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<HttpResponse<ArrayBuffer>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<ArrayBuffer>>: An Observable of the HTTPResponse for the request, with the response body as an ArrayBuffer.

Overload #10

Constructs a GET request that interprets the body as a Blob and returns the full HTTPResponse.

get(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<HttpResponse<Blob>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<Blob>>: An Observable of the HTTPResponse for the request, with the response body as a Blob.

Overload #11

Constructs a GET request that interprets the body as a text stream and returns the full HTTPResponse.

get(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<HttpResponse<string>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<string>>: An Observable of the HTTPResponse for the request, with the response body of type string.

Overload #12

Constructs a GET request that interprets the body as a JSON object and returns the full HTTPResponse.

get(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpResponse<Object>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<Object>>: An Observable of the full HttpResponse, with the response body of type Object.

Overload #13

Constructs a GET request that interprets the body as a JSON object and returns the full HTTPResponse.

get<T>(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpResponse<T>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<T>>: An Observable of the full HTTPResponse for the request, with a response body in the requested type.

Overload #14

Constructs a GET request that interprets the body as a JSON object and returns the response body as a JSON object.

get(url: string, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<Object>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Optional. Default is undefined.

Returns

Observable<Object>: An Observable of the response body as a JSON object.

Overload #15

Constructs a GET request that interprets the body as a JSON object and returns the response body in a given type.

get<T>(url: string, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<T>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Optional. Default is undefined.

Returns

Observable<T>: An Observable of the HTTPResponse, with a response body in the requested type.

Constructs an observable that, when subscribed, causes the configured HEAD request to execute on the server. The HEAD method returns meta information about the resource without transferring the resource itself. See the individual overloads for details on the return type.

15 overloads...

Show All Hide All
Overload #1

Constructs a HEAD request that interprets the body as an ArrayBuffer and returns the response as an ArrayBuffer.

head(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<ArrayBuffer>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<ArrayBuffer>: An Observable of the response, with the response body as an ArrayBuffer.

Overload #2

Constructs a HEAD request that interprets the body as a Blob and returns the response as a Blob.

head(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<Blob>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<Blob>: An Observable of the response, with the response body as a Blob.

Overload #3

Constructs a HEAD request that interprets the body as a text string and returns the response as a string value.

head(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<string>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<string>: An Observable of the response, with the response body of type string.

Overload #4

Constructs a HEAD request that interprets the body as an ArrayBuffer and returns the full event stream.

head(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<HttpEvent<ArrayBuffer>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<ArrayBuffer>>: An Observable of tall HttpEvents for the request, with the response body as an ArrayBuffer.

Overload #5

Constructs a HEAD request that interprets the body as a Blob and returns the full event stream.

head(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<HttpEvent<Blob>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<Blob>>: An Observable of all HttpEvents for the request, with the response body as a Blob.

Overload #6

Constructs a HEAD request that interprets the body as a text string and returns the full event stream.

head(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<HttpEvent<string>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<string>>: An Observable of all HttpEvents for the request, with the response body of type string.

Overload #7

Constructs a HEAD request that interprets the body as a JSON object and returns the full HTTP event stream.

head(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpEvent<Object>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<Object>>: An Observable of all HTTPEvents for the request, with a response body of type Object.

Overload #8

Constructs a HEAD request that interprets the body as a JSON object and returns the full event stream.

head<T>(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpEvent<T>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpEvent<T>>: An Observable of all the HTTPEvents for the request , with a response body in the requested type.

Overload #9

Constructs a HEAD request that interprets the body as an ArrayBuffer and returns the full HTTP response.

head(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<HttpResponse<ArrayBuffer>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<ArrayBuffer>>: An Observable of the HTTPResponse for the request, with the response body as an ArrayBuffer.

Overload #10

Constructs a HEAD request that interprets the body as a Blob and returns the full HTTPResponse.

head(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<HttpResponse<Blob>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<Blob>>: An Observable of the HTTPResponse for the request, with the response body as a blob.

Overload #11

Constructs a HEAD request that interprets the body as text stream and returns the full HTTPResponse.

head(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<HttpResponse<string>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<string>>: An Observable of the HTTPResponse for the request, with the response body of type string.

Overload #12

Constructs a HEAD request that interprets the body as a JSON object and returns the full HTTPResponse.

head(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpResponse<Object>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<Object>>: An Observable of the HTTPResponse for the request, with the response body of type Object.

Overload #13

Constructs a HEAD request that interprets the body as a JSON object and returns the full HTTPResponse.

head<T>(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpResponse<T>>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Returns

Observable<HttpResponse<T>>: An Observable of the HTTPResponse for the request, with a responmse body of the requested type.

Overload #14

Constructs a HEAD request that interprets the body as a JSON object and returns the response body as a JSON object.

head(url: string, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<Object>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Optional. Default is undefined.

Returns

Observable<Object>: An Observable of the response, with the response body as a JSON object.

Overload #15

Constructs a HEAD request that interprets the body as a JSON object and returns the response in a given type.

head<T>(url: string, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<T>

Parameters
url string

The endpoint URL.

options object

The HTTP options to send with the request.

Optional. Default is undefined.

Returns

Observable<T>: An Observable of the HTTPResponse for the request, with a response body of the given type.

Constructs an Observable that, when subscribed, causes a request with the special method JSONP to be dispatched via the interceptor pipeline. The JSONP pattern works around limitations of certain API endpoints that don't support newer, and preferable CORS protocol. JSONP treats the endpoint API as a JavaScript file and tricks the browser to process the requests even if the API endpoint is not located on the same domain (origin) as the client-side application making the request. The endpoint API must support JSONP callback for JSONP requests to work. The resource API returns the JSON response wrapped in a callback function. You can pass the callback function name as one of the query parameters. Note that JSONP requests can only be used with GET requests.

Constructs a JSONP request for the given URL and name of the callback parameter.

jsonp(url: string, callbackParam: string): Observable<Object>

Parameters
url string

The resource URL.

callbackParam string

The callback function name.

Returns

Observable<Object>: An Observable of the response object, with response body as an object.

Constructs a JSONP request for the given URL and name of the callback parameter.

jsonp<T>(url: string, callbackParam: string): Observable<T>

Parameters
url string

The resource URL.

callbackParam string

The callback function name.

You must install a suitable interceptor, such as one provided by HttpClientJsonpModule. If no such interceptor is reached, then the JSONP request can be rejected by the configured backend.

Returns

Observable<T>: An Observable of the response object, with response body in the requested type.

Constructs an Observable that, when subscribed, causes the configured OPTIONS request to execute on the server. This method allows the client to determine the supported HTTP methods and other capabilites of an endpoint, without implying a resource action. See the individual overloads for details on the return type.

15 overloads...

Show All Hide All
Overload #1

Constructs an OPTIONS request that interprets the body as an ArrayBuffer and returns the response as an ArrayBuffer.

options(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<ArrayBuffer>

Parameters
url string

The endpoint URL.

options object

HTTP options.

Returns

Observable<ArrayBuffer>: An Observable of the response, with the response body as an ArrayBuffer.

Overload #2

Constructs an OPTIONS request that interprets the body as a Blob and returns the response as a Blob.

options(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<Blob>

Parameters
url string

The endpoint URL.

options object

HTTP options.

Returns

Observable<Blob>: An Observable of the response, with the response body as a Blob.

Overload #3

Constructs an OPTIONS request that interprets the body as a text string and returns a string value.

options(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<string>

Parameters
url string

The endpoint URL.

options object

HTTP options.

Returns

Observable<string>: An Observable of the response, with the response body of type string.

Overload #4

Constructs an OPTIONS request that interprets the body as an ArrayBuffer and returns the full event stream.

options(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<HttpEvent<ArrayBuffer>>

Parameters
url string

The endpoint URL.

options object

HTTP options.

Returns

Observable<HttpEvent<ArrayBuffer>>: An Observable of all HttpEvents for the request, with the response body as an ArrayBuffer.

Overload #5

Constructs an OPTIONS request that interprets the body as a Blob and returns the full event stream.

options(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<HttpEvent<Blob>>

Parameters
url string

The endpoint URL.

options object

HTTP options.

Returns

Observable<HttpEvent<Blob>>: An Observable of all HttpEvents for the request, with the response body as a Blob.

Overload #6

Constructs an OPTIONS request that interprets the body as a text string and returns the full event stream.

options(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<HttpEvent<string>>

Parameters
url string

The endpoint URL.

options object

HTTP options.

Returns

Observable<HttpEvent<string>>: An Observable of all the HTTPEvents for the request, with the response body of type string.

Overload #7

Constructs an OPTIONS request that interprets the body as a JSON object and returns the full event stream.

options(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpEvent<Object>>

Parameters
url string

The endpoint URL.

options object

HTTP options.

Returns

Observable<HttpEvent<Object>>: An Observable of all the HttpEvents for the request with the response body of type Object.

Overload #8

Constructs an OPTIONS request that interprets the body as a JSON object and returns the full event stream.

options<T>(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpEvent<T>>

Parameters
url string

The endpoint URL.

options object

HTTP options.

Returns

Observable<HttpEvent<T>>: An Observable of all the HttpEvents for the request, with a response body in the requested type.

Overload #9

Constructs an OPTIONS request that interprets the body as an ArrayBuffer and returns the full HTTP response.

options(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<HttpResponse<ArrayBuffer>>

Parameters
url string

The endpoint URL.

options object

HTTP options.

Returns

Observable<HttpResponse<ArrayBuffer>>: An Observable of the HttpResponse for the request, with the response body as an ArrayBuffer.

Overload #10

Constructs an OPTIONS request that interprets the body as a Blob and returns the full HTTPResponse.

options(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<HttpResponse<Blob>>

Parameters
url string

The endpoint URL.

options object

HTTP options.

Returns

Observable<HttpResponse<Blob>>: An Observable of the HttpResponse for the request, with the response body as a Blob.

Overload #11

Constructs an OPTIONS request that interprets the body as text stream and returns the full HTTPResponse.

options(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<HttpResponse<string>>

Parameters
url string

The endpoint URL.

options object

HTTP options.

Returns

Observable<HttpResponse<string>>: An Observable of the HttpResponse for the request, with the response body of type string.

Overload #12

Constructs an OPTIONS request that interprets the body as a JSON object and returns the full HTTPResponse.

options(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpResponse<Object>>

Parameters
url string

The endpoint URL.

options object

HTTP options.

Returns

Observable<HttpResponse<Object>>: An Observable of the HttpResponse for the request, with the response body of type Object.

Overload #13

Constructs an OPTIONS request that interprets the body as a JSON object and returns the full HTTPResponse.

options<T>(url: string, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpResponse<T>>

Parameters
url string

The endpoint URL.

options object

HTTP options.

Returns

Observable<HttpResponse<T>>: An Observable of the HttpResponse for the request, with a response body in the requested type.

Overload #14

Constructs an OPTIONS request that interprets the body as a JSON object and returns the response body as a JSON object.

options(url: string, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<Object>

Parameters
url string

The endpoint URL.

options object

HTTP options.

Optional. Default is undefined.

Returns

Observable<Object>: An Observable of the response, with the response body as a JSON object.

Overload #15

Constructs an OPTIONS request that interprets the body as a JSON object and returns the response in a given type.

options<T>(url: string, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<T>

Parameters
url string

The endpoint URL.

options object

HTTP options.

Optional. Default is undefined.

Returns

Observable<T>: An Observable of the HTTPResponse, with a response body of the given type.

Constructs an observable that, when subscribed, causes the configured PATCH request to execute on the server. See the individual overloads for details on the return type.

15 overloads...

Show All Hide All
Overload #1

Constructs a PATCH request that interprets the body as an ArrayBuffer and returns the response as an ArrayBuffer.

patch(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<ArrayBuffer>

Parameters
url string

The endpoint URL.

body any

The resources to edit.

options object

HTTP options.

Returns

Observable<ArrayBuffer>: An Observable of the response, with the response body as an ArrayBuffer.

Overload #2

Constructs a PATCH request that interprets the body as a Blob and returns the response as a Blob.

patch(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<Blob>

Parameters
url string

The endpoint URL.

body any

The resources to edit.

options object

HTTP options.

Returns

Observable<Blob>: An Observable of the response, with the response body as a Blob.

Overload #3

Constructs a PATCH request that interprets the body as a text string and returns the response as a string value.

patch(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<string>

Parameters
url string

The endpoint URL.

body any

The resources to edit.

options object

HTTP options.

Returns

Observable<string>: An Observable of the response, with a response body of type string.

Overload #4

Constructs a PATCH request that interprets the body as an ArrayBuffer and returns the the full event stream.

patch(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<HttpEvent<ArrayBuffer>>

Parameters
url string

The endpoint URL.

body any

The resources to edit.

options object

HTTP options.

Returns

Observable<HttpEvent<ArrayBuffer>>: An Observable of all the HTTPevents for the request, with the response body as an ArrayBuffer.

Overload #5

Constructs a PATCH request that interprets the body as a Blob and returns the full event stream.

patch(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<HttpEvent<Blob>>

Parameters
url string

The endpoint URL.

body any

The resources to edit.

options object

HTTP options.

Returns

Observable<HttpEvent<Blob>>: An Observable of all the HTTPevents for the request, with the response body as Blob.

Overload #6

Constructs a PATCH request that interprets the body as a text string and returns the full event stream.

patch(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<HttpEvent<string>>

Parameters
url string

The endpoint URL.

body any

The resources to edit.

options object

HTTP options.

Returns

Observable<HttpEvent<string>>: An Observable of all the HTTPeventsfor the request, with a response body of type string.

Overload #7

Constructs a PATCH request that interprets the body as a JSON object and returns the full event stream.

patch(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpEvent<Object>>

Parameters
url string

The endpoint URL.

body any

The resources to edit.

options object

HTTP options.

Returns

Observable<HttpEvent<Object>>: An Observable of all the HTTPevents for the request, with a response body of type Object.

Overload #8

Constructs a PATCH request that interprets the body as a JSON object and returns the full event stream.

patch<T>(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpEvent<T>>

Parameters
url string

The endpoint URL.

body any

The resources to edit.

options object

HTTP options.

Returns

Observable<HttpEvent<T>>: An Observable of all the HTTPevents for the request, with a response body in the requested type.

Overload #9

Constructs a PATCH request that interprets the body as an ArrayBuffer and returns the full HTTPResponse.

patch(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<HttpResponse<ArrayBuffer>>

Parameters
url string

The endpoint URL.

body any

The resources to edit.

options object

HTTP options.

Returns

Observable<HttpResponse<ArrayBuffer>>: An Observable of the HttpResponse for the request, with the response body as an ArrayBuffer.

Overload #10

Constructs a PATCH request that interprets the body as a Blob and returns the full HTTPResponse.

patch(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<HttpResponse<Blob>>

Parameters
url string

The endpoint URL.

body any

The resources to edit.

options object

HTTP options.

Returns

Observable<HttpResponse<Blob>>: An Observable of the HttpResponse for the request, with the response body as a Blob.

Overload #11

Constructs a PATCH request that interprets the body as a text stream and returns the full HTTPResponse.

patch(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<HttpResponse<string>>

Parameters
url string

The endpoint URL.

body any

The resources to edit.

options object

HTTP options.

Returns

Observable<HttpResponse<string>>: An Observable of the HttpResponse for the request, with a response body of type string.

Overload #12

Constructs a PATCH request that interprets the body as a JSON object and returns the full HTTPResponse.

patch(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpResponse<Object>>

Parameters
url string

The endpoint URL.

body any

The resources to edit.

options object

HTTP options.

Returns

Observable<HttpResponse<Object>>: An Observable of the HttpResponse for the request, with a response body in the requested type.

Overload #13

Constructs a PATCH request that interprets the body as a JSON object and returns the full HTTPResponse.

patch<T>(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpResponse<T>>

Parameters
url string

The endpoint URL.

body any

The resources to edit.

options object

HTTP options.

Returns

Observable<HttpResponse<T>>: An Observable of the HttpResponse for the request, with a response body in the given type.

Overload #14

Constructs a PATCH request that interprets the body as a JSON object and returns the response body as a JSON object.

patch(url: string, body: any, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<Object>

Parameters
url string

The endpoint URL.

body any

The resources to edit.

options object

HTTP options.

Optional. Default is undefined.

Returns

Observable<Object>: An Observable of the response, with the response body as a JSON object.

Overload #15

Constructs a PATCH request that interprets the body as a JSON object and returns the response in a given type.

patch<T>(url: string, body: any, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<T>

Parameters
url string

The endpoint URL.

body any

The resources to edit.

options object

HTTP options.

Optional. Default is undefined.

Returns

Observable<T>: An Observable of the HttpResponse for the request, with a response body in the given type.

Constructs an observable that, when subscribed, causes the configured POST request to execute on the server. The server responds with the location of the replaced resource. See the individual overloads for details on the return type.

15 overloads...

Show All Hide All
Overload #1

Constructs a POST request that interprets the body as an ArrayBuffer and returns an ArrayBuffer.

post(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<ArrayBuffer>

Parameters
url string

The endpoint URL.

body any

The content to replace with.

options object

HTTP options.

Returns

Observable<ArrayBuffer>: An Observable of the response, with the response body as an ArrayBuffer.

Overload #2

Constructs a POST request that interprets the body as a Blob and returns the response as a Blob.

post(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<Blob>

Parameters
url string

The endpoint URL.

body any

The content to replace with.

options object

HTTP options

Returns

Observable<Blob>: An Observable of the response, with the response body as a Blob.

Overload #3

Constructs a POST request that interprets the body as a text string and returns the response as a string value.

post(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<string>

Parameters
url string

The endpoint URL.

body any

The content to replace with.

options object

HTTP options

Returns

Observable<string>: An Observable of the response, with a response body of type string.

Overload #4

Constructs a POST request that interprets the body as an ArrayBuffer and returns the full event stream.

post(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<HttpEvent<ArrayBuffer>>

Parameters
url string

The endpoint URL.

body any

The content to replace with.

options object

HTTP options

Returns

Observable<HttpEvent<ArrayBuffer>>: An Observable of all HttpEvents for the request, with the response body as an ArrayBuffer.

Overload #5

Constructs a POST request that interprets the body as a Blob and returns the response in an observable of the full event stream.

post(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<HttpEvent<Blob>>

Parameters
url string

The endpoint URL.

body any

The content to replace with.

options object

HTTP options

Returns

Observable<HttpEvent<Blob>>: An Observable of all HttpEvents for the request, with the response body as Blob.

Overload #6

Constructs a POST request that interprets the body as a text string and returns the full event stream.

post(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<HttpEvent<string>>

Parameters
url string

The endpoint URL.

body any

The content to replace with.

options object

HTTP options

Returns

Observable<HttpEvent<string>>: An Observable of all HttpEvents for the request, with a response body of type string.

Overload #7

Constructs a POST request that interprets the body as a JSON object and returns the full event stream.

post(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpEvent<Object>>

Parameters
url string

The endpoint URL.

body any

The content to replace with.

options object

HTTP options

Returns

Observable<HttpEvent<Object>>: An Observable of all HttpEvents for the request, with a response body of type Object.

Overload #8

Constructs a POST request that interprets the body as a JSON object and returns the full event stream.

post<T>(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpEvent<T>>

Parameters
url string

The endpoint URL.

body any

The content to replace with.

options object

HTTP options

Returns

Observable<HttpEvent<T>>: An Observable of all HttpEvents for the request, with a response body in the requested type.

Overload #9

Constructs a POST request that interprets the body as an ArrayBuffer and returns the full HTTPresponse.

post(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<HttpResponse<ArrayBuffer>>

Parameters
url string

The endpoint URL.

body any

The content to replace with.

options object

HTTP options

Returns

Observable<HttpResponse<ArrayBuffer>>: An Observable of the HTTPResponse for the request, with the response body as an ArrayBuffer.

Overload #10

Constructs a POST request that interprets the body as a Blob and returns the full HTTPResponse.

post(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<HttpResponse<Blob>>

Parameters
url string

The endpoint URL.

body any

The content to replace with.

options object

HTTP options

Returns

Observable<HttpResponse<Blob>>: An Observable of the HTTPResponse for the request, with the response body as a Blob.

Overload #11

Constructs a POST request that interprets the body as a text stream and returns the full HTTPResponse.

post(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<HttpResponse<string>>

Parameters
url string

The endpoint URL.

body any

The content to replace with.

options object

HTTP options

Returns

Observable<HttpResponse<string>>: An Observable of the HTTPResponse for the request, with a response body of type string.

Overload #12

Constructs a POST request that interprets the body as a JSON object and returns the full HTTPResponse.

post(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpResponse<Object>>

Parameters
url string

The endpoint URL.

body any

The content to replace with.

options object

HTTP options

Returns

Observable<HttpResponse<Object>>: An Observable of the HTTPResponse for the request, with a response body of type Object.

Overload #13

Constructs a POST request that interprets the body as a JSON object and returns the full HTTPResponse.

post<T>(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpResponse<T>>

Parameters
url string

The endpoint URL.

body any

The content to replace with.

options object

HTTP options

Returns

Observable<HttpResponse<T>>: An Observable of the HTTPResponse for the request, with a response body in the requested type.

Overload #14

Constructs a POST request that interprets the body as a JSON object and returns the response body as a JSON object.

post(url: string, body: any, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<Object>

Parameters
url string

The endpoint URL.

body any

The content to replace with.

options object

HTTP options

Optional. Default is undefined.

Returns

Observable<Object>: An Observable of the response, with the response body as a JSON object.

Overload #15

Constructs a POST request that interprets the body as a JSON object and returns an observable of the response.

post<T>(url: string, body: any, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<T>

Parameters
url string

The endpoint URL.

body any

The content to replace with.

options object

HTTP options

Optional. Default is undefined.

Returns

Observable<T>: An Observable of the HTTPResponse for the request, with a response body in the requested type.

Constructs an observable that, when subscribed, causes the configured PUT request to execute on the server. The PUT method replaces an existing resource with a new set of values. See the individual overloads for details on the return type.

15 overloads...

Show All Hide All
Overload #1

Constructs a PUT request that interprets the body as an ArrayBuffer and returns the response as an ArrayBuffer.

put(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<ArrayBuffer>

Parameters
url string

The endpoint URL.

body any

The resources to add/update.

options object

HTTP options

Returns

Observable<ArrayBuffer>: An Observable of the response, with the response body as an ArrayBuffer.

Overload #2

Constructs a PUT request that interprets the body as a Blob and returns the response as a Blob.

put(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<Blob>

Parameters
url string

The endpoint URL.

body any

The resources to add/update.

options object

HTTP options

Returns

Observable<Blob>: An Observable of the response, with the response body as a Blob.

Overload #3

Constructs a PUT request that interprets the body as a text string and returns the response as a string value.

put(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<string>

Parameters
url string

The endpoint URL.

body any

The resources to add/update.

options object

HTTP options

Returns

Observable<string>: An Observable of the response, with a response body of type string.

Overload #4

Constructs a PUT request that interprets the body as an ArrayBuffer and returns the full event stream.

put(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<HttpEvent<ArrayBuffer>>

Parameters
url string

The endpoint URL.

body any

The resources to add/update.

options object

HTTP options

Returns

Observable<HttpEvent<ArrayBuffer>>: An Observable of all HttpEvents for the request, with the response body as an ArrayBuffer.

Overload #5

Constructs a PUT request that interprets the body as a Blob and returns the full event stream.

put(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<HttpEvent<Blob>>

Parameters
url string

The endpoint URL.

body any

The resources to add/update.

options object

HTTP options

Returns

Observable<HttpEvent<Blob>>: An Observable of all HttpEvents for the request, with the response body as a Blob.

Overload #6

Constructs a PUT request that interprets the body as a text string and returns the full event stream.

put(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<HttpEvent<string>>

Parameters
url string

The endpoint URL.

body any

The resources to add/update.

options object

HTTP options

Returns

Observable<HttpEvent<string>>: An Observable of all HttpEvents for the request, with a response body of type string.

Overload #7

Constructs a PUT request that interprets the body as a JSON object and returns the full event stream.

put(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpEvent<Object>>

Parameters
url string

The endpoint URL.

body any

The resources to add/update.

options object

HTTP options

Returns

Observable<HttpEvent<Object>>: An Observable of all HttpEvents for the request, with a response body of type Object.

Overload #8

Constructs a PUT request that interprets the body as a JSON object and returns the full event stream.

put<T>(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "events"; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpEvent<T>>

Parameters
url string

The endpoint URL.

body any

The resources to add/update.

options object

HTTP options

Returns

Observable<HttpEvent<T>>: An Observable of all HttpEvents for the request, with a response body in the requested type.

Overload #9

Constructs a PUT request that interprets the body as an ArrayBuffer and returns an observable of the full HTTP response.

put(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "arraybuffer"; withCredentials?: boolean; }): Observable<HttpResponse<ArrayBuffer>>

Parameters
url string

The endpoint URL.

body any

The resources to add/update.

options object

HTTP options

Returns

Observable<HttpResponse<ArrayBuffer>>: An Observable of the HTTPResponse for the request, with the response body as an ArrayBuffer.

Overload #10

Constructs a PUT request that interprets the body as a Blob and returns the full HTTP response.

put(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "blob"; withCredentials?: boolean; }): Observable<HttpResponse<Blob>>

Parameters
url string

The endpoint URL.

body any

The resources to add/update.

options object

HTTP options

Returns

Observable<HttpResponse<Blob>>: An Observable of the HTTPResponse for the request, with the response body as a Blob.

Overload #11

Constructs a PUT request that interprets the body as a text stream and returns the full HTTP response.

put(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType: "text"; withCredentials?: boolean; }): Observable<HttpResponse<string>>

Parameters
url string

The endpoint URL.

body any

The resources to add/update.

options object

HTTP options

Returns

Observable<HttpResponse<string>>: An Observable of the HTTPResponse for the request, with a response body of type string.

Overload #12

Constructs a PUT request that interprets the body as a JSON object and returns the full HTTP response.

put(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpResponse<Object>>

Parameters
url string

The endpoint URL.

body any

The resources to add/update.

options object

HTTP options

Returns

Observable<HttpResponse<Object>>: An Observable of the HTTPResponse for the request, with a response body of type 'Object`.

Overload #13

Constructs a PUT request that interprets the body as an instance of the requested type and returns the full HTTP response.

put<T>(url: string, body: any, options: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe: "response"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<HttpResponse<T>>

Parameters
url string

The endpoint URL.

body any

The resources to add/update.

options object

HTTP options

Returns

Observable<HttpResponse<T>>: An Observable of the HTTPResponse for the request, with a response body in the requested type.

Overload #14

Constructs a PUT request that interprets the body as a JSON object and returns an observable of JSON object.

put(url: string, body: any, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<Object>

Parameters
url string

The endpoint URL.

body any

The resources to add/update.

options object

HTTP options

Optional. Default is undefined.

Returns

Observable<Object>: An Observable of the response as a JSON object.

Overload #15

Constructs a PUT request that interprets the body as an instance of the requested type and returns an observable of the requested type.

put<T>(url: string, body: any, options?: { headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: HttpParams | { [param: string]: string | string[]; }; reportProgress?: boolean; responseType?: "json"; withCredentials?: boolean; }): Observable<T>

Parameters
url string

The endpoint URL.

body any

The resources to add/update.

options object

HTTP options

Optional. Default is undefined.

Returns

Observable<T>: An Observable of the requested type.

Usage notes

Sample HTTP requests for the Tour of Heroes application.

HTTP Request Example

// GET heroes whose name contains search term
searchHeroes(term: string): observable<Hero[]>{

 const params = new HttpParams({fromString: 'name=term'});
   return this.httpClient.request('GET', this.heroesUrl, {responseType:'json', params});
}

JSONP Example

requestJsonp(url, callback = 'callback') {
 return this.httpClient.jsonp(this.heroesURL, callback);
}

PATCH Example

// PATCH one of the heroes' name
patchHero (id: number, heroName: string): Observable<{}> {
const url = `${this.heroesUrl}/${id}`;   // PATCH api/heroes/42
 return this.httpClient.patch(url, {name: heroName}, httpOptions)
   .pipe(catchError(this.handleError('patchHero')));
}

© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v10.angular.io/api/common/http/HttpClient