Skip to content

Commit cd0b0b6

Browse files
Updated api paths.
1 parent 17df82d commit cd0b0b6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/components/jobs/PostsTable.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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.')

src/components/jobs/SubscribeButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const SubscribeButton: React.FC = () => {
1717

1818
console.log('Subscribing to notifications:', subData)
1919

20-
await fetch('/api/subscribe', {
20+
await fetch('/api/notifications/subscribe', {
2121
method: 'POST',
2222
headers: { 'Content-Type': 'application/json' },
2323
body: JSON.stringify(subData),

0 commit comments

Comments
 (0)