Response.error()

翻译不完整。 请帮助我们翻译这篇文章!

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

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

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

语法

var errorResponse = Response.error();

参数

返回值

一个 Response 对象

示例

TBD (does not yet appear to be supported anywhere).

规范

规范 状态 注释
Fetch
error()
Living Standard

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
error
Experimental
Chrome Full support YesEdge Full support 16Firefox Full support YesIE No support NoOpera Full support YesSafari Full support YesWebView Android No support NoChrome Android No support NoFirefox Android No support NoOpera Android No support NoSafari iOS No support NoSamsung Internet Android No support No

Legend

Full support  
Full support
No support  
No support
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.

See also