jacobinathanialpeterson commited on
Commit
5b6d515
·
1 Parent(s): b74cad3

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +11 -4
static/script.js CHANGED
@@ -1,7 +1,7 @@
1
  const DELAYTIME = 500
2
  let DATA;
3
 
4
- function postMessage(url="https://jacobinathanialpeterson-chatbox.hf.space/postMessage") {
5
  const controller = new AbortController();
6
  const abortSignal = controller.signal;
7
  fetch(url, {
@@ -9,7 +9,7 @@ function postMessage(url="https://jacobinathanialpeterson-chatbox.hf.space/postM
9
  headers: {
10
  'Content-Type': 'application/json'
11
  },
12
- body: JSON.stringify({nameInput: document.getElementById("nameInputBox").value, messageInput: document.getElementById("messageInputBox").value}),
13
  signal: abortSignal
14
  })
15
  .then(response => { if (!response.ok) { throw new Error('Network response was not ok.') } return response.json() })
@@ -19,10 +19,17 @@ function postMessage(url="https://jacobinathanialpeterson-chatbox.hf.space/postM
19
  .catch(error => { if (error.name === 'AbortError') { console.log('Fetch aborted:', error.message) } else { console.error('Error fetching data:', error.message) }});
20
  }
21
 
22
- function getMessages(url="https://jacobinathanialpeterson-chatbox.hf.space/messages") {
23
  const controller = new AbortController();
24
  const abortSignal = controller.signal;
25
- fetch(url, {signal: abortSignal})
 
 
 
 
 
 
 
26
  .then(response => { if (!response.ok) { throw new Error('Network response was not ok.') } return response.json() })
27
  .then(data => {
28
  // Get the keys of the object
 
1
  const DELAYTIME = 500
2
  let DATA;
3
 
4
+ function postMessage(url="https://jacobinathanialpeterson-chatbox2.hf.space/postMessage") {
5
  const controller = new AbortController();
6
  const abortSignal = controller.signal;
7
  fetch(url, {
 
9
  headers: {
10
  'Content-Type': 'application/json'
11
  },
12
+ body: JSON.stringify({nameInput: document.getElementById("nameInputBox").value, messageInput: document.getElementById("messageInputBox").value, roomIdInput: "123"}),
13
  signal: abortSignal
14
  })
15
  .then(response => { if (!response.ok) { throw new Error('Network response was not ok.') } return response.json() })
 
19
  .catch(error => { if (error.name === 'AbortError') { console.log('Fetch aborted:', error.message) } else { console.error('Error fetching data:', error.message) }});
20
  }
21
 
22
+ function getMessages(url="https://jacobinathanialpeterson-chatbox2.hf.space/messages") {
23
  const controller = new AbortController();
24
  const abortSignal = controller.signal;
25
+ fetch(url, {
26
+ method: 'POST',
27
+ headers: {
28
+ 'Content-Type': 'application/json'
29
+ },
30
+ body: JSON.stringify({roomIdInput: "123"}),
31
+ signal: abortSignal
32
+ })
33
  .then(response => { if (!response.ok) { throw new Error('Network response was not ok.') } return response.json() })
34
  .then(data => {
35
  // Get the keys of the object