Frontend: Improve status polling in server.js
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
parent
8bfd95ddc4
commit
b4ecadda9d
1 changed files with 10 additions and 1 deletions
|
@ -36,8 +36,17 @@ function poll(interval, maxAttempts) {
|
|||
try {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", config.apiUri + "/status", false);
|
||||
xhr.onload = function () {
|
||||
if (this.status === 200) {
|
||||
return resolve();
|
||||
} else {
|
||||
throw new Error("request failed");
|
||||
}
|
||||
};
|
||||
xhr.onerror = function () {
|
||||
throw new Error("request failed");
|
||||
};
|
||||
xhr.send();
|
||||
return resolve();
|
||||
} catch {
|
||||
if (maxAttempts && attempts === maxAttempts) {
|
||||
return reject(new Error("exceeded max attempts"));
|
||||
|
|
Loading…
Reference in a new issue