Network Request Async Communication
Network Request Async Communication
The APIs for network requests include: XMLHttpRequest, Fetch, Beacon, EventSource, and WebSocket.
- XMLHttpRequest: The
XMLHttpRequestobject allows the browser to interact with a server, enabling data retrieval from the server without refreshing the page. - Fetch: The
FetchAPI is an interface similar to theXMLHttpRequestAPI. Since it is based on Promises, it operates asynchronously. - Beacon: The
BeaconAPI 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:
EventSourceenables servers to send real-time events to clients; connections established via this API operate over HTTP. - WebSocket:
WebSocketallows 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.