Skip to main content
InterviewHubPRO
Section Overview
Q62

Question 62 of 536

Part 2: Promises, Callbacks, Async & Strict Mode (54 - 103)

12%
JavaScript & V8 Internals (536 Qs)•Part 2: Promises, Callbacks, Async & Strict Mode (54 - 103)

How do you receive server-sent event notifications

mid LevelMost AskedCode ExampleAsync & Promises

The EventSource object is used to receive server-sent event notifications. For example, you can receive messages from server as below,

javascript
if (typeof EventSource !== "undefined") {
  var source = new EventSource("sse_generator.js");
  source.onmessage = function (event) {
    document.getElementById("output").innerHTML += event.data + "<br>";
  };
}