# Class: HttpService

## HttpService

#### new HttpService()

Superclass for services communicating using HTTP, usually REST services.

Source:
  - data/service/http-service.js, line 84

### Classes

DataType

### Members

#### authorizationHeaderName :string

Name of header to be passed to all requests along with authorizationHeaderValue

##### Type:

- string

Source:
  - data/service/http-service.js, line 142

#### authorizationHeaderValue :string

Value of header with name authorizationHeaderName to include with all requests from this service

##### Type:

- string

Source:
  - data/service/http-service.js, line 151

#### authorizationHeaderValueExpression :string

FRB Expression defining the authorizationHeaderValue when evaluated against a DataQuery passed to this service.

##### Type:

- string

Source:
  - data/service/http-service.js, line 161

#### FORM_URL_ENCODED :Object.<string, string>

The Content-Type header corresponding to application/x-www-form-urlencoded, the default format of form data.

##### Type:

- Object.<string, string>

Source:
  - data/service/http-service.js, line 97

#### FORM_URL_ENCODED_CONTENT_TYPE_HEADER :Object.<string, string>

##### Type:

- Object.<string, string>

Deprecated:
  - in favor of FORM_URL_ENCODED.
Source:
  - data/service/http-service.js, line 106

### Methods

#### _authRegexp(url, headersopt, bodyopt, typesopt, sendCredentialsopt) → {external:Promise}

Fetches raw data from an HTTP REST endpoint.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`url` | String |  |  | The URL of the endpoint.
`headers` | Object.<string, string> | <optional> | {} | HTTP header names and values. Optional except if a body or types are to be specified. Pass in an empty, null, or undefined header to specify a body or types but no header.
`body` |  | <optional> |  | The body to send with the XMLHttpRequest. Optional except if types are to be specified. Pass in a null or undefined body to specify types but no body.
`types` | Array.<HttpService.DataType> | <optional> | [HttpService.DataType.JSON] | The possible types of the data expected in responses. These will be used to parse the response data. Currently only the first type is taken into account. The types can be specified as an array or as a sequence of DataType arguments.
`sendCredentials` | boolean | <optional> | true | Determines whether credentials are sent with the request.

Source:
  - data/service/http-service.js, line 285

##### Returns:

- A promise settled when the fetch is complete. On success the promise will be fulfilled with the data returned from the fetch, parsed according to the specified or detaul types. On error the promise will be rejected with the error.

Type
  external:Promise