解码 ReadableByteStreams
Decoding ReadableByteStreams
var url = 'http://www.googleapis.com/customsearch/v1?q=foo&searchType=image';
window.fetch(url)
.then(decode)
.catch(err => console.log(err));
function decode(r) {
// r.body is a ReadableByteStream - how do I decode it to a string?
}
r.body
是一个 ReadableByteStream
- 我如何将它解码为字符串?
decode
是正确的术语吗?
内置解码器用于此目的:
window.fetch(url)
.then(r => r.text())
.catch(err => console.log(err));
var url = 'http://www.googleapis.com/customsearch/v1?q=foo&searchType=image';
window.fetch(url)
.then(decode)
.catch(err => console.log(err));
function decode(r) {
// r.body is a ReadableByteStream - how do I decode it to a string?
}
r.body
是一个 ReadableByteStream
- 我如何将它解码为字符串?
decode
是正确的术语吗?
内置解码器用于此目的:
window.fetch(url)
.then(r => r.text())
.catch(err => console.log(err));