Browse API 1 documentation
GroveAPI 1preview

response.text()

Decode a native network response body as UTF-8.

Mango 3.1+View Markdown

Decode a native network response body as UTF-8.

Signature

ts
response.text(): string

Availability

On the response returned by grove.network.request. It is not a global function.

Parameters

None.

Return value

Returns a string synchronously, not a Promise.

Behavior and errors

Uses TextDecoder’s UTF-8 decoding, independent of the Content-Type charset. Invalid UTF-8 sequences use replacement characters. It does not consume the body: repeated calls decode the current body bytes again. Decoding a body does not mean the HTTP status was successful.

Example

js
const response = await grove.network.request('https://api.example.com/version')
if (!response.ok) throw new Error('Version request failed')
const version = response.text()

See grove.network.request().