@@ -20,7 +20,7 @@ const PostsTable: React.FC<Props> = ({ posts, totalPosts, postsPerPage, currentP
2020 navigator . serviceWorker
2121 . register ( '/sw.js' )
2222 . then ( ( registration ) => console . log ( 'Service Worker registered:' , registration ) )
23- . catch ( ( error ) => console . log ( 'Service Worker registration failed:' , error ) ) //error( )
23+ . catch ( ( error ) => console . error ( 'Service Worker registration failed:' , error ) )
2424 }
2525 } , [ ] )
2626
@@ -42,11 +42,11 @@ const PostsTable: React.FC<Props> = ({ posts, totalPosts, postsPerPage, currentP
4242 const registration = await navigator . serviceWorker . ready
4343
4444 // Fetch the public VAPID key from the server
45- const response = await fetch ( '/api/get-public-key' )
45+ const response = await fetch ( '/api/notifications/ get-public-key' )
4646 if ( ! response . ok ) throw new Error ( 'Failed to fetch public key' )
4747 const { publicKey } = await response . json ( )
4848
49- // Convert VAPID key to the format r
49+ // Convert VAPID key to the format required by PushManager
5050 const convertedVapidKey = urlBase64ToUint8Array ( publicKey )
5151
5252 // Subscribe the user to push notifications
@@ -56,7 +56,7 @@ const PostsTable: React.FC<Props> = ({ posts, totalPosts, postsPerPage, currentP
5656 } )
5757
5858 // Send the subscription to the server
59- const subscribeResponse = await fetch ( '/api/subscribe' , {
59+ const subscribeResponse = await fetch ( '/api/notifications/ subscribe' , {
6060 method : 'POST' ,
6161 body : JSON . stringify ( subscription ) ,
6262 headers : {
@@ -68,7 +68,7 @@ const PostsTable: React.FC<Props> = ({ posts, totalPosts, postsPerPage, currentP
6868 alert ( 'Successfully subscribed to notifications!' )
6969 setIsSubscribed ( true )
7070 } catch ( error ) {
71- console . log ( 'Error during subscription:' , error ) //error( )
71+ console . error ( 'Error during subscription:' , error )
7272 }
7373 } else {
7474 alert ( 'Push messaging is not supported in your browser.' )
0 commit comments