[Vuejs]-How do I show a HTTP stream in a Vue.js app

0👍

I followed this document to handle streams on the frontend:
https://developer.mozilla.org/en-US/docs/Web/API/Streams_API/Using_readable_streams

fetch('/apiURL')
.then(response=> {
   const reader = reader.body.getReader()
   let data = []
   return reader.read().then(read = (result)=>{
     if(result.done){
       return data
     }

     data.push(result.value)
     return reader.read().then(read)
   })
})
.then(data => {
   // Do whatever you want with your data
})

Leave a comment