Arcader7171 commited on
Commit
712b502
·
verified ·
1 Parent(s): 9f43c4a

Update templates/app.html

Browse files
Files changed (1) hide show
  1. templates/app.html +8 -5
templates/app.html CHANGED
@@ -39,7 +39,7 @@
39
 
40
  function sendMessage(msgContent) {
41
  let heads = new Headers();
42
- let creds = window.btoa("{{ session['username'] }}" + ":" + "{{ session['password'] }}")
43
  heads.append("Authorization", `Basic ${creds}`);
44
  heads.append("Content-Type", "application/json");
45
  fetch("/api/messages", {
@@ -49,12 +49,15 @@
49
  })
50
  .then(response => {
51
  if (!response.ok) {
52
- throw new Error("Response did not return ok")
53
  }
54
  response.json()
55
  })
56
  .then((data) => {
57
-
 
 
 
58
  })
59
  }
60
 
@@ -89,8 +92,8 @@
89
  supabase // supabase will eventually be replaced for SSE and realtime! Check back soon
90
  .channel("main/general")
91
  .on("broadcast", { event: 'new_message', schema: 'public', table: 'messages' }, payload => {
92
- console.log("New message received") // Temp for dev lol
93
- checkForMessage(payload)
94
  })
95
  </script>
96
  </body>
 
39
 
40
  function sendMessage(msgContent) {
41
  let heads = new Headers();
42
+ let creds = window.btoa("{{ session['username'] }}" + ":" + "{{ session['password'] }}");
43
  heads.append("Authorization", `Basic ${creds}`);
44
  heads.append("Content-Type", "application/json");
45
  fetch("/api/messages", {
 
49
  })
50
  .then(response => {
51
  if (!response.ok) {
52
+ throw new Error("Response did not return ok");
53
  }
54
  response.json()
55
  })
56
  .then((data) => {
57
+ addMsg2View(data);
58
+ })
59
+ .catch(error => {
60
+ console.error("Error - ", error.message);
61
  })
62
  }
63
 
 
92
  supabase // supabase will eventually be replaced for SSE and realtime! Check back soon
93
  .channel("main/general")
94
  .on("broadcast", { event: 'new_message', schema: 'public', table: 'messages' }, payload => {
95
+ console.log("New message received"); // Temp for dev lol
96
+ checkForMessage(payload);
97
  })
98
  </script>
99
  </body>