async function postSubscription()

in Lab/Exercise3/02-End/Contoso.Dashboard/js/sb-pwa.js [43:55]


async function postSubscription(subscription) {
  try {
    let response = await fetch('http://localhost:5000/api/push/channel', {
      method: 'post',
      headers: { 'Content-type': 'application/json' },
      body: JSON.stringify({ subscription: subscription })
    });
    console.log('[PWALab] The push subscription has been stored succesfully');
  }
  catch (error) {
    console.log('[PWALab] Error saving the subscription: ' + error);
  }
}