MDN Web Docs

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

Help improve MDN

Yes No

Learn how to contribute

This page was last modified on by MDN contributors.

Read the original on developer.mozilla.org ↗