files/en-us/web/api/request/text/index.md
{{APIRef("Fetch API")}}{{AvailableInWorkers}}
The text() method of the {{domxref("Request")}} interface
reads the request body and returns it as a promise that resolves with a {{jsxref("String")}}.
The response is always decoded using UTF-8.
text()
None.
A Promise that resolves with a {{jsxref("String")}}.
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}}
{{Compat}}