async function expectFetchLater(
    init, {targetUrl = undefined, uuid = undefined} = {}) {
  if ((targetUrl && !uuid) || (!targetUrl && uuid)) {
    throw new Error('uuid and targetUrl must be provided together.');
  }
  if (uuid && targetUrl && !targetUrl.includes(uuid)) {
    throw new Error(`Conflicting uuid=${
        uuid} is provided: must also be included in the targetUrl ${
        targetUrl}`);
  }
  if (!uuid) {
    uuid = token();
  }
  if (!targetUrl) {
    targetUrl = generateSetBeaconURL(uuid);
  }

  fetchLater(targetUrl, init);

  await expectBeacon(uuid, {count: 1});
}
A helper to make a fetchLater request and wait for it being received.

This function can also be used when the caller does not care about where a
fetchLater() makes request to.

@param {!RequestInit} init The request config to pass into fetchLater() call.