new OAuth2Response()
A response from a fetch request.
This class represents a secure response from a Oauth2 fetch call.
A fetch is a simplified HTTP response from a protected resource.
Methods
body() → {Buffer}
The HTTP response body as a buffer
Returns:
a buffer with the HTTP response body
- Type
- Buffer
getHeader(name) → {string}
Looks up a HTTP response header by name, in case where the response is a list of headers,
the first one is returned.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | of the header to look up |
Returns:
the single value for the header.
- Type
- string
headers() → {MultiMap}
The HTTP response headers from the HTTP layer.
Returns:
the HTTP headers
- Type
- MultiMap
is(contentType) → {boolean}
Helper to analize the response body. The test is performed against the header Content-Type,
the content of the body is not analyzed.
Parameters:
| Name | Type | Description |
|---|---|---|
contentType |
string | a content type to test, e.g.: application/json |
Returns:
true if the header matches
- Type
- boolean
jsonArray() → {Array}
The HTTP response body as a JsonArray
Returns:
a JsonArray from the HTTP response body
- Type
- Array
jsonObject() → {Object}
The HTTP response body as a JsonObject
Returns:
a JsonObject from the HTTP response body
- Type
- Object
statusCode() → {number}
the returned status code from the HTTP layer.
Returns:
HTTP status code
- Type
- number