Response.error()

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.

Response 接口的 error() 方法返回一个包含网络错误相关信息的新 Response 对象。

备注: 这主要与 Service Workers 有关;如果你愿意,可以使用 error 方法返回错误。错误响应的 type 被设置为 error

备注: 一个“错误”的 Response 不会真正地暴露给脚本:例如 fetch() 的“错误”响应将会返回 promise 的 reject 状态。

语法

js
Response.error()

参数

返回值

一个 Response 对象。

示例

待定(似乎还没有在任何地方得到支持)。

规范

Specification
Fetch
# ref-for-dom-response-error①

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
error() static method

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参见