BaseRequestOptions
class
deprecated
npm Package | @angular/http |
---|---|
Module | import { BaseRequestOptions } from '@angular/http'; |
Source | http/src/base_request_options.ts |
Deprecation Notes
use @angular/common/http instead
Overview
class BaseRequestOptions extends RequestOptions { constructor() // inherited from http/RequestOptions 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 }
Description
Subclass of RequestOptions
, with default values.
Default values:
- method: RequestMethod.Get
- headers: empty
Headers
object
This class could be extended and bound to the RequestOptions
class when configuring an Injector
, in order to override the default options used by Http
to create and send Requests.
import {BaseRequestOptions, RequestOptions} from '@angular/http'; class MyOptions extends BaseRequestOptions { search: string = 'coreTeam=true'; } {provide: RequestOptions, useClass: MyOptions};
The options could also be extended when manually creating a Request
object.
import {BaseRequestOptions, Request, RequestMethod} from '@angular/http'; const options = new BaseRequestOptions(); const req = new Request(options.merge({ method: RequestMethod.Post, 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
Constructor
constructor()
Annotations
@Injectable()
© 2010–2018 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v5.angular.io/api/http/BaseRequestOptions