-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
32 lines (29 loc) · 978 Bytes
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
document.addEventListener('DOMContentLoaded', function() {
const input = document.getElementById("inputId");
let query = ""
if (input) {
input.addEventListener("input", function() {
query = input.value;
console.log('Query:', query);
})} else {
console.error(" No input");
}
const button = document.getElementById("SubmitButton");
if (button) {
button.addEventListener("click", function() {
console.log("button is clicked")
fetch(`http://127.0.0.1:5000/api/search?query=${query}`, {
mode: "cors"})
.then(response => response.json())
.then(data => {
const summary = data.summary;
const output = document.getElementById("output");
output.innerText = summary;
console.log(data)
})
.catch(error => {
console.error("Error", error);
});
});
}
});