Network Request Async Communication

Network Request Async Communication

The APIs for network requests include: XMLHttpRequest, Fetch, Beacon, EventSource, and WebSocket.

  • XMLHttpRequest: The XMLHttpRequest object allows the browser to interact with a server, enabling data retrieval from the server without refreshing the page.
  • Fetch: The Fetch API is an interface similar to the XMLHttpRequest API. Since it is based on Promises, it operates asynchronously.
  • Beacon: The Beacon API is used to send asynchronous and non-blocking requests to a server. Browsers ensure that Beacon requests are initialized and completed before the page unloads. This API is commonly utilized for sending analytics data to servers.
  • EventSource: EventSource enables servers to send real-time events to clients; connections established via this API operate over HTTP.
  • WebSocket: WebSocket allows a browser to establish a bidirectional, full-duplex connection with a server, facilitating the exchange of text and binary messages between them. WebSocket connections do not use the HTTP protocol but instead utilize the WebSocket protocol.