Challenge 1
Send a fire-and-forget payload with the classic API.
const queued = navigator.('/api/collect', JSON.stringify(payload));
Press Ctrl⌘Enter to check your answer
Fill in the missing pieces of the sendBeacon signature, boolean contract, and realm checks.
Challenge 1
const queued = navigator.('/api/collect', JSON.stringify(payload));
Press Ctrl⌘Enter to check your answer
Challenge 2
if (!navigator.sendBeacon(url, body)) {
// only fires on quota overflow at queueing time
(payload); // stash for the next page load
}
Press Ctrl⌘Enter to check your answer
Challenge 3
export function inWindowContext() {
return typeof !== 'undefined';
}
Press Ctrl⌘Enter to check your answer
Challenge 4
export function workerBeacon(url, data) {
return fetch(url, {
method: 'POST',
body: data,
: true,
}).then(() => true).catch(() => false);
}
Press Ctrl⌘Enter to check your answer
Challenge 5
// throws TypeError synchronously:
navigator.sendBeacon(, body);
Press Ctrl⌘Enter to check your answer