What Http Method Does Eventsource Use To Open A Connection?
While in other questions people claimt EventSource is fairly well documented I have found it to be more implied then explicit in some cases. My understanding is that when you initi
Solution 1:
The request method when using the EventSource
interface is a GET
request. You can include a query string in the URL passed to the constructor and parse the query string at the server.
const stream = "data: event stream\n\n";
const blob = newBlob([stream], {type:"text/event-stream"});
const blobURL = URL.createObjectURL(blob);
const es = newEventSource(blobURL);
es.onmessage = e => {
console.log(e.data);
}
es.onerror = e => {
es.close();
}
Post a Comment for "What Http Method Does Eventsource Use To Open A Connection?"