HTML:标记语言
CSS:样式语言
JavaScript:脚本语言
Web API:编程接口
所有 Web 技术
学习 Web 开发
发现我们的工具
更好地了解 MDN
此特性已得到良好确立,可跨多种设备和浏览器版本使用。自 2017 年 3 月起,所有浏览器均支持此特性。
注意:此功能在 Web Workers 中可用。
Request 接口的 text() 方法读取请求体并将其作为 Promise 返回,该 Promise 解析为 String。响应始终使用 UTF-8 进行解码。
Request
text()
String
无。
一个解析为 String 的 Promise。
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 });
加载中…
Response.text()