Class: Response

LuCI.Response

The Response class is an internal utility class representing HTTP responses.

Source:

Members

duration :number

The total duration of the HTTP request in milliseconds

Type:
  • number
Source:

headers :LuCI.Headers

The HTTP headers of the response

Type:
Source:

ok :boolean

Describes whether the response is successful (status codes 200..299) or not

Type:
  • boolean
Source:

status :number

The numeric HTTP status code of the response

Type:
  • number
Source:

statusText :string

The HTTP status description message of the response

Type:
  • string
Source:

url :string

The final URL of the request, i.e. after following redirects.

Type:
  • string
Source:

Methods

clone(contentopt) → {LuCI.Response}

Clones the given response object, optionally overriding the content of the cloned instance.

Parameters:
Name Type Attributes Description
content * <optional>

Override the content of the cloned response. Object values will be treated as JSON response data, all other types will be converted using String() and treated as response text.

Source:
Returns:

The cloned Response instance.

Type
LuCI.Response

json() → {*}

Access the response content as JSON data.

Source:
Throws:

Throws SyntaxError if the content isn't valid JSON.

Type
SyntaxError
Returns:

The parsed JSON data.

Type
*

text() → {string}

Access the response content as string.

Source:
Returns:

The response content.

Type
string