mirror of
https://github.com/Crocmagnon/buzzer.git
synced 2024-12-26 07:51:51 +01:00
Add timeout to javascript queries
This commit is contained in:
parent
3e936313d5
commit
372cf830ae
1 changed files with 3 additions and 5 deletions
|
@ -1,13 +1,11 @@
|
|||
function play() {
|
||||
console.log("Play...");
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.open("GET", "play", true);
|
||||
xhttp.send();
|
||||
fetch("/play", { signal: AbortSignal.timeout(7000) });
|
||||
}
|
||||
|
||||
function loadAvailableFiles() {
|
||||
console.log("Available files...");
|
||||
fetch("/available-files")
|
||||
fetch("/available-files", { signal: AbortSignal.timeout(7000) })
|
||||
.then(response => response.json())
|
||||
.then(handleAvailableFiles);
|
||||
}
|
||||
|
@ -16,7 +14,7 @@ function selectFile(name) {
|
|||
console.log("Select file");
|
||||
const body = new FormData();
|
||||
body.set("fileName", name);
|
||||
fetch("/select-file", {method: "POST", body: body})
|
||||
fetch("/select-file", { method: "POST", body: body, signal: AbortSignal.timeout(7000) })
|
||||
.then(response => response.json())
|
||||
.then(handleAvailableFiles);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue