export class RequestOptions
export class RequestOptions
exported from angular2/http defined in angular2/src/http/base_request_options.ts (line 7)
Creates a request options object to be optionally provided when instantiating a
Request
.
This class is based on the RequestInit
description in the Fetch
Spec.
All values are null by default. Typical defaults can be found in the BaseRequestOptions
class, which sub-classes RequestOptions
.
Example (live demo)
Constructor
constructor({method, headers, body, url, search}?: RequestOptionsArgs)
constructor({method, headers, body, url, search}?: RequestOptionsArgs)
Not Yet Documented
Members
method : RequestMethod | string
method : RequestMethod | string
Http method with which to execute a Request
.
Acceptable methods are defined in the RequestMethod
enum.
body : string
body : string
Body to be used when creating a Request
.
url : string
url : string
Url with which to perform a Request
.
search : URLSearchParams
search : URLSearchParams
Search parameters to be included in a Request
.
merge(options?: RequestOptionsArgs) : RequestOptions
merge(options?: RequestOptionsArgs) : RequestOptions
Creates a copy of the RequestOptions
instance, using the optional input as values to override
existing values. This method will not change the values of the instance on which it is being
called.
Note that headers
and search
will override existing values completely if present in
the options
object. If these values should be merged, it should be done prior to calling
merge
on the RequestOptions
instance.
(live demo)
import {RequestOptions, Request, RequestMethod} from 'angular2/http';
var options = new RequestOptions({
method: RequestMethod.Post
});
var req = new Request(options.merge({
url: 'https://google.com'
}));
console.log('req.method:', RequestMethod[req.method]); // Post
console.log('options.url:', options.url); // null
console.log('req.url:', req.url); // https://google.com