LuCI. response

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

Members

duration :number

The total duration of the HTTP request in milliseconds

Type:
  • number

headers :LuCI.headers

The HTTP headers of the response

ok :boolean

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

Type:
  • boolean

status :number

The numeric HTTP status code of the response

Type:
  • number

statusText :string

The HTTP status description message of the response

Type:
  • string

url :string

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

Type:
  • string

Methods

blob() → {Blob}

Access the response content as blob.

Returns:

The response content as blob.

Type: 
Blob

clone(contentopt) → {LuCI.response}

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

Parameters:
NameTypeAttributesDescription
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:

The cloned Response instance.

Type: 
LuCI.response

json() → {*}

Access the response content as JSON data.

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.

Returns:

The response content.

Type: 
string