小编str*_*605的帖子

Response.text() 承诺什么时候会拒绝?

我看到MDN/Response/text.text()文档上显示了仅使用的示例then

response.text().then(function (text) {
  // do something with the text response
});
Run Code Online (Sandbox Code Playgroud)

它返回一个用字符串解析的承诺。

由于 lint 规则,我需要放置

// eslint-disable-next-line @typescript-eslint/no-floating-promises
res.text().then(async (t) => {
Run Code Online (Sandbox Code Playgroud)

当我需要捕获被拒绝的承诺时,是否有用例Response.text()?也许一些例子?

javascript promise fetch-api

6
推荐指数
1
解决办法
1643
查看次数

标签 统计

fetch-api ×1

javascript ×1

promise ×1