?
This commit is contained in:
parent
57f3197a39
commit
6ffe15ef9f
@ -27,10 +27,16 @@ async function readResponse(response) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
function read() {
|
function read() {
|
||||||
|
let finishedResponse = '';
|
||||||
// Recursive function to read the stream
|
// Recursive function to read the stream
|
||||||
reader.read().then(( chunk ) => {
|
reader.read().then(( chunk ) => {
|
||||||
console.log(`Done: ${JSON.stringify(chunk.done)}`);
|
console.log(`Done: ${JSON.stringify(chunk.done)}`);
|
||||||
console.log(`Value: ${new TextDecoder().decode(chunk.value)}`);
|
console.log(`Value: ${new TextDecoder().decode(chunk.value)}`);
|
||||||
|
if (chunk.value) {
|
||||||
|
const text = decoder.decode(chunk.value, { stream: true });
|
||||||
|
finishedResponse += text;
|
||||||
|
outputArea.innerHTML = finishedResponse;
|
||||||
|
}
|
||||||
if (chunk.done) {
|
if (chunk.done) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user