I'm trying to implement a custom built service worker into my Nuxt JS site. I'm getting an error after generating the site as follows:
Cannot read property 'register' of undefined
function Notify (siteOptions) {
/* Set Dependancies */
this.siteOptions = siteOptions /* Register Applicant */
this.register()
} /** * Register Service Worker */
Notify.prototype.register = function () {
/** * Test Registration */
navigator.serviceWorker.register('Notify-service-worker.js').then(function (registration) {
console.log('SW: Available')
}).catch(function (error) {
console.error('SW: Not Available', error)
})
It appears that this is the line causing issues:
navigator.serviceWorker.register('Notify-service-worker.js')