DEV Community

Discussion on: Sure you want to leave?—browser beforeunload event

Collapse
 
jalson1982 profile image
Jalson1982

Any idea how to perform graphql mutation with sendBeacon?

Collapse
 
samthor profile image
Sam Thorogood

Well, you send off a POST request with sendBeacon. You'd tell your server (on some HTTP handler) to do something, but you wouldn't be able to see whether the result was successful.

Collapse
 
jalson1982 profile image
Jalson1982

The issue with this I can not set headers or on some way control it. I am using synchronous XMLHttp request, it runs on all browsers but slows down a little navigation and it is not also the most happier solution. I do not need to see the result I just need to save analytics data to db on browser close.