I am trying to stream live data using kafka to our company's website so that I can display a live updating plot.
I have a working JS consumer which I wrote with help from the kafkaJS docs.
Now I want to call this script from an HTML file on our website so that it can read all the incoming data and plot it.
var source = new EventSource('script.js');
source.addEventListener('message', function(e){
console.log('Message')
obj = JSON.parse(e.data);
console.log(obj);
})
On my site this is the error I receive:
EventSource's response has a MIME type ("application/javascript") that is not "text/event-stream". Aborting the connection.
I am not sure if I am heading in the right direction or if this is even possible I am a big noob here and I am struggling to find useful resources.
Any help or guidance would be greatly appreciated.
Thanks a lot
Kafka is a backend service, and therefore KafkaJS would be a backend client.
If you want to stream data to a frontend client (i.e. the browser), you'd want SSE, Websockets, or other streaming HTTP traffic, which KafkaJS itself does not provide.