Class: Response

LuCI. Response

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

new LuCI.Response()

luci.js, line 377

Members

durationnumber

The total duration of the HTTP request in milliseconds

headersLuCI.Headers

The HTTP headers of the response

okboolean

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

statusnumber

The numeric HTTP status code of the response

statusTextstring

The HTTP status description message of the response

urlstring

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

Methods

clone(content){LuCI.Response}

luci.js, line 465

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

Name Type 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.

Returns:
Type Description
LuCI.Response The cloned Response instance.

json(){*}

luci.js, line 486

Access the response content as JSON data.

Throws:

Throws SyntaxError if the content isn't valid JSON.

Type
SyntaxError
Returns:
Type Description
* The parsed JSON data.

text(){string}

luci.js, line 501

Access the response content as string.

Returns:
Type Description
string The response content.