提交 2d0d174b 编写于 作者: D David Graham

Fix response body example.

The initial promise is resolved when the response headers are
available, not necessarily when the entire body has been received. The
body must be processed by resolving another promise (text, json, blob).
上级 bee911f6
......@@ -26,9 +26,12 @@ example requests.
### HTML
```javascript
fetch('/users.html').then(function(response) {
document.body.innerHTML = response.body
})
fetch('/users.html')
.then(function(response) {
return response.text()
}).then(function(body) {
document.body.innerHTML = body
})
```
### JSON
......@@ -52,7 +55,6 @@ fetch('/users.json').then(function(response) {
console.log(response.headers.get('Date'))
console.log(response.status)
console.log(response.statusText)
console.log(response.body)
})
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册