Content-Length: 171851 | pFad | https://developer.mozilla.org/en-US/docs/Web/API/Request/text

Request: text() method - Web APIs | MDN

Request: text() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.

Note: This feature is available in Web Workers.

The text() method of the Request interface reads the request body and returns it as a promise that resolves with a String. The response is always decoded using UTF-8.

Syntax

js
text()

Parameters

None.

Return value

A Promise that resolves with a String.

Exceptions

TypeError

Thrown for one of the following reasons:

Examples

js
const text = "Hello world";

const request = new Request("/myEndpoint", {
  method: "POST",
  body: text,
});

request.text().then((text) => {
  // do something with the text sent in the request
});

Specifications

Specification
Fetch
# ref-for-dom-body-text①

Browser compatibility

See also









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://developer.mozilla.org/en-US/docs/Web/API/Request/text

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy