diff --git a/src/assets/js/main.js b/src/assets/js/main.js index 0f8ade0..038f87d 100644 --- a/src/assets/js/main.js +++ b/src/assets/js/main.js @@ -27,10 +27,16 @@ async function readResponse(response) { try { function read() { + let finishedResponse = ''; // Recursive function to read the stream reader.read().then(( chunk ) => { console.log(`Done: ${JSON.stringify(chunk.done)}`); 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) { return; }