Class: Response

LuCI. Response

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

new LuCI.Response()

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

blob(){Blob}

Access the response content as blob.

Returns:
Type Description
Blob The response content as blob.

clone(content){LuCI.Response}

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(){*}

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}

Access the response content as string.

Returns:
Type Description
string The response content.