Is it possible to get the sendBeacon HTTP result?

112 Views Asked by At

I am sending data using sendBeacon. Every time I send a beacon, I also know that the user's login session was extended, so I also update a timestamp in a sessionStorage key whenever I send a beacon to the current time.

But, sometimes a user returns after the session ends, and then the POST code from the sendBeacon is 419, yet the timestamp still updates but that affects other scripts that rely on that sessionStorage timestamp

Is there any way to then get the HTTP code from the POST of the sendBeacon and update the timestamp only if it succeeded? the return values for sendBeacon are only true/false if it successfully sent it, but nothing to do with the result itself.

But maybe there is still a way to get the HTTP result in a different way? I know I can change that to fetch or AJAX, but I am specifically using sendBeacon for analytics as described in the docs so I thought it's the best use case for it here

0

There are 0 best solutions below