From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/response/error/index.html | 63 +++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 files/zh-cn/web/api/response/error/index.html (limited to 'files/zh-cn/web/api/response/error') diff --git a/files/zh-cn/web/api/response/error/index.html b/files/zh-cn/web/api/response/error/index.html new file mode 100644 index 0000000000..57bdd13a0c --- /dev/null +++ b/files/zh-cn/web/api/response/error/index.html @@ -0,0 +1,63 @@ +--- +title: Response.error() +slug: Web/API/Response/error +translation_of: Web/API/Response/error +--- +
{{APIRef("Fetch")}}
+ +

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

+ +
+

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

+
+ +
+

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

+
+ +

语法

+ +
var errorResponse = Response.error();
+ +

参数

+ +

+ +

返回值

+ +

一个 {{domxref("Response")}} 对象

+ +

示例

+ +

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

+ +

规范

+ + + + + + + + + + + + + + +
规范状态注释
{{SpecName('Fetch','#dom-response-error','error()')}}{{Spec2('Fetch')}}
+ +

Browser compatibility

+ + + +

{{Compat("api.Response.error")}}

+ +

See also

+ + -- cgit v1.2.3-54-g00ecf