So, I have a stream of data in the form of a shite ton of strings from a node server sending to localhost:8080/path-name/ and I have my html at the root. ultimately I have other streams of data sending to other path names, so I may have a localhost:8080/other-path-name/ as well. The stream page if I go to it directly may look something like:
LOOTS OF STRINGSSSS
HOLY CRAP ANOTHER STRING
I AM A STRING
DATA DATA DATA!!!
THIS IS A STREAM OF STRINGSSS
and so on...
What I want to do is put these streams into separate div so I can see all their streams on 1 page. Here is what I've done so far:
<body>
<button onclick="streamGet">click me</button>
<div class="stream">
</div>
<script>
function streamGet(){
fetch("/path-name").on('data', (ev) => {
let element = document.querySelector('.stream');
element.innertext.ev.data.toString('utf-8');
});
}
</script>
This doesn't work. What am I messing up? I'll be happy to take suggestion on better ways to do this if there are any as well.
via Ryan Tibbetts
No comments:
Post a Comment