Frontend: Improve status polling in server.js
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
parent
8bfd95ddc4
commit
b4ecadda9d
|
@ -36,8 +36,17 @@ function poll(interval, maxAttempts) {
|
||||||
try {
|
try {
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
xhr.open("GET", config.apiUri + "/status", false);
|
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();
|
xhr.send();
|
||||||
return resolve();
|
|
||||||
} catch {
|
} catch {
|
||||||
if (maxAttempts && attempts === maxAttempts) {
|
if (maxAttempts && attempts === maxAttempts) {
|
||||||
return reject(new Error("exceeded max attempts"));
|
return reject(new Error("exceeded max attempts"));
|
||||||
|
|
Loading…
Reference in a new issue