MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey

这篇翻译不完整。请帮忙从英语翻译这篇文章


Response  接口的status 只读属性包含响应的状态代码(例如,成功为200)。

Syntax

let myStatus = response.status;

Value

A number (to be precise, an unsigned short).

Example

In our Fetch Response example (see Fetch Response live) we create a new Request object using the Request() constructor, passing it a JPG path. We then fetch this request using fetch(), extract a blob from the response using Body.blob, create an object URL out of it using URL.createObjectURL, and display this in an <img>.

Note that at the top of the fetch() block we log the response status value to the console.

var myImage = document.querySelector('img');

var myRequest = new Request('flowers.jpg');

fetch(myRequest).then(function(response) {
  console.log(response.status); // returns 200
  response.blob().then(function(myBlob) {
    var objectURL = URL.createObjectURL(myBlob);
    myImage.src = objectURL;
  });
});

Specifications

Specification Status Comment
Fetch
status
Living Standard Initial definition

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 42
41[1]
(Yes) 39 (39)
34[1]
未实现

29
28[1]

未实现
Feature Android Edge Firefox Mobile (Gecko) Firefox OS (Gecko) IE Phone Opera Mobile Safari Mobile Chrome for Android
Basic support 未实现 (Yes) 未实现 未实现 未实现 未实现 未实现 未实现

[1] This feature is implemented behind a preference.

See also

文档标签和贡献者

标签: 
 此页面的贡献者: xgqfrms-GitHub
 最后编辑者: xgqfrms-GitHub,