TheVera commited on
Commit
6fa3e37
·
verified ·
1 Parent(s): 9b025cd

Update script.js

Browse files
Files changed (1) hide show
  1. script.js +9 -9
script.js CHANGED
@@ -9,7 +9,7 @@ document.addEventListener('DOMContentLoaded', function() {
9
  // Check token validity with backend
10
  fetch('https://thevera-botveradb.hf.space/validate_token', {
11
  method: 'GET',
12
- headers: {
13
  'Authorization': `Bearer ${token}`
14
  }
15
  })
@@ -257,17 +257,17 @@ function sendMessage() {
257
  },
258
  body: JSON.stringify(requestData)
259
  });
260
- .then(response => {
 
261
  if (!response.ok) {
262
- throw new Error('Failed to store chat data');
263
  }
264
  return response.json();
265
  })
266
- .then(data => {
267
- console.log(data.message); // Log success message
268
- // Enable the micButton after response
269
- micButton.disabled = false;
270
- })
271
  })
272
  .catch(error => {
273
  alert('Failed to connect to the backend. Please try again later.');
@@ -275,7 +275,7 @@ function sendMessage() {
275
  // Enable the voiceInputBtn after error
276
  micButton.disabled = false;
277
  });
278
- }
279
  }
280
 
281
  let isFirstMessage = true; // Flag to track if it's the first message
 
9
  // Check token validity with backend
10
  fetch('https://thevera-botveradb.hf.space/validate_token', {
11
  method: 'GET',
12
+ headers: {
13
  'Authorization': `Bearer ${token}`
14
  }
15
  })
 
257
  },
258
  body: JSON.stringify(requestData)
259
  });
260
+ })
261
+ .then(response => {
262
  if (!response.ok) {
263
+ throw new Error('Failed to store chat data');
264
  }
265
  return response.json();
266
  })
267
+ .then(data => {
268
+ console.log(data.message); // Log success message
269
+ // Enable the micButton after response
270
+ micButton.disabled = false;
 
271
  })
272
  .catch(error => {
273
  alert('Failed to connect to the backend. Please try again later.');
 
275
  // Enable the voiceInputBtn after error
276
  micButton.disabled = false;
277
  });
278
+ }
279
  }
280
 
281
  let isFirstMessage = true; // Flag to track if it's the first message