summaryrefslogtreecommitdiff
path: root/frontend/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/main.js')
-rw-r--r--frontend/main.js26
1 files changed, 14 insertions, 12 deletions
diff --git a/frontend/main.js b/frontend/main.js
index 3f5c4c4..3ce5fb1 100644
--- a/frontend/main.js
+++ b/frontend/main.js
@@ -31,24 +31,26 @@ async function subscribe() {
userVisibleOnly: true,
applicationServerKey: urlBase64ToUint8Array(PUBLIC_VAPID_KEY),
});
+
console.log(subscription);
+
+ console.log("sw regis pass, write to db");
+
+ const db_reply = await fetch(`${API_URL}/notifsubscribe`, {
+ method: 'POST',
+ credentials: "include",
+ body: JSON.stringify(subscription),
+ headers: {
+ "Content-Type": "application/json",
+ },
+ });
+
+ return db_reply.status == 2000;
} catch (e) {
console.log("ERR in regis, ", e);
return false;
}
- console.log("sw regis pass, write to db");
-
- const db_reply = await fetch(`${API_URL}/notifsubscribe`, {
- method: 'POST',
- credentials: "include",
- body: JSON.stringify(subscription),
- headers: {
- "Content-Type": "application/json",
- },
- });
-
- return db_reply.status == 2000;
}
/// copied from somewhere