sendBeacon method
The navigator.sendBeacon()
method sends an
HTTP POST
request containing a small amount of data to a web server.
It's intended to be used for sending analytics data to a web server, and avoids some of the problems with legacy techniques for sending analytics, such as the use of XMLHttpRequest.
Note: For use cases that need the ability to send requests with methods other than
POST
, or to change any request properties, or that need access to the server response, instead use thefetch()
method withkeepalive
set to true.
Implementation
external bool sendBeacon(
String url, [
BodyInit? data,
]);