Skip to content

Commit

Permalink
feat: test beforeunload compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Leoglme committed Feb 18, 2024
1 parent 4a299fe commit fee8698
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions public/mon-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@

if (window.fetch) {
console.log('fetch')
await fetch(apiUrl + '/leave', {
await fetch(apiUrl, {
body: JSON.stringify(data),
method: 'POST',
keepalive: true,
})
} else if (navigator.sendBeacon && Blob.prototype.isPrototypeOf(blob)) {
console.log('sendBeacon')
const beaconSent = navigator.sendBeacon(apiUrl + '/leave', blob)
const beaconSent = navigator.sendBeacon(apiUrl, blob)

if (!beaconSent) {
console.log('!beaconSent')
Expand Down

0 comments on commit fee8698

Please sign in to comment.