RequestOptions
Creates a request options object to be optionally provided when instantiating a Request
.
已弃用: see https://angular.io/guide/http
class RequestOptions {
constructor(opts: RequestOptionsArgs = {})
method: RequestMethod | string | null
headers: Headers | null
body: any
url: string | null
params: URLSearchParams
search: URLSearchParams
withCredentials: boolean | null
responseType: ResponseContentType | null
merge(options?: RequestOptionsArgs): RequestOptions
}
说明
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
.
import {RequestOptions, Request, RequestMethod} from '@angular/http';
const options = new RequestOptions({
method: RequestMethod.Post,
url: 'https://google.com'
});
const req = new Request(options);
console.log('req.method:', RequestMethod[req.method]); // Post
console.log('options.url:', options.url); // https://google.com
构造函数
属性
属性 | 说明 |
---|---|
method: RequestMethod | string | null | Http method with which to execute a |
headers: Headers | null | Headers to be attached to a |
body: any | Body to be used when creating a |
url: string | null | Url with which to perform a |
params: URLSearchParams | Search parameters to be included in a |
search: URLSearchParams | |
withCredentials: boolean | null | Enable use credentials for a |
responseType: ResponseContentType | null |
方法
Creates a copy of the | |||
参数
返回值 | |||
Note that
|