BaseRequestOptions

class deprecated

Subclass of RequestOptions, with default values.

See more...

Deprecated: see https://angular.io/guide/http

class BaseRequestOptions extends RequestOptions {

  // inherited from http/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
}

Description

Default values:

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

© 2010–2019 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v7.angular.io/api/http/BaseRequestOptions