@@ -20,7 +20,7 @@ const PostsTable: React.FC<Props> = ({ posts, totalPosts, postsPerPage, currentP
20
20
navigator . serviceWorker
21
21
. register ( '/sw.js' )
22
22
. 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 ) )
24
24
}
25
25
} , [ ] )
26
26
@@ -42,11 +42,11 @@ const PostsTable: React.FC<Props> = ({ posts, totalPosts, postsPerPage, currentP
42
42
const registration = await navigator . serviceWorker . ready
43
43
44
44
// 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' )
46
46
if ( ! response . ok ) throw new Error ( 'Failed to fetch public key' )
47
47
const { publicKey } = await response . json ( )
48
48
49
- // Convert VAPID key to the format r
49
+ // Convert VAPID key to the format required by PushManager
50
50
const convertedVapidKey = urlBase64ToUint8Array ( publicKey )
51
51
52
52
// Subscribe the user to push notifications
@@ -56,7 +56,7 @@ const PostsTable: React.FC<Props> = ({ posts, totalPosts, postsPerPage, currentP
56
56
} )
57
57
58
58
// Send the subscription to the server
59
- const subscribeResponse = await fetch ( '/api/subscribe' , {
59
+ const subscribeResponse = await fetch ( '/api/notifications/ subscribe' , {
60
60
method : 'POST' ,
61
61
body : JSON . stringify ( subscription ) ,
62
62
headers : {
@@ -68,7 +68,7 @@ const PostsTable: React.FC<Props> = ({ posts, totalPosts, postsPerPage, currentP
68
68
alert ( 'Successfully subscribed to notifications!' )
69
69
setIsSubscribed ( true )
70
70
} catch ( error ) {
71
- console . log ( 'Error during subscription:' , error ) //error( )
71
+ console . error ( 'Error during subscription:' , error )
72
72
}
73
73
} else {
74
74
alert ( 'Push messaging is not supported in your browser.' )
0 commit comments