Realtime (at Eventsource), how to fix console errors?

Realtime project (on Eventsource) written by React + node (the data on the graph is updated every 10 minutes). Everything works, only errors appear in the console ( Can anyone tell me how to remove these errors?

Server:

router.get('/connect', (req, res) => {
res.writeHead(200, {
    Connection: 'keep-alive',
    'Content-Type': 'text/event-stream',
    'Cache-Control': 'no-cache',
})
emitter.on('dataChart', (message) => {
    res.write(`data: ${JSON.stringify(message)} \n\n`)
})

})

Client:

    useEffect(() => {

     const eventSource = new EventSource('http://localhost:5000/api/gsm/connect')
     eventSource.onmessage = function (event) {
     setDataChart(JSON.parse(event.data))
    }

}, [])

viewing a picture with errors



Read more here: https://stackoverflow.com/questions/66998348/realtime-at-eventsource-how-to-fix-console-errors

Content Attribution

This content was originally published by dragon at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: