mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fix unhandled rejection for invalid response
This commit is contained in:
parent
01dba76f36
commit
df1f111320
1 changed files with 13 additions and 17 deletions
|
@ -50,30 +50,26 @@ export async function serverAddress() {
|
||||||
console.debug('URL candidates:', urls);
|
console.debug('URL candidates:', urls);
|
||||||
|
|
||||||
const promises = urls.map(url => {
|
const promises = urls.map(url => {
|
||||||
return fetch(`${url}/System/Info/Public`).then(resp => {
|
return fetch(`${url}/System/Info/Public`)
|
||||||
return {
|
.then(async resp => {
|
||||||
url: url,
|
if (!resp.ok) {
|
||||||
response: resp
|
return;
|
||||||
};
|
}
|
||||||
}).catch(() => {
|
|
||||||
return Promise.resolve();
|
return {
|
||||||
});
|
url: url,
|
||||||
|
config: await resp.json()
|
||||||
|
};
|
||||||
|
}).catch(() => { /* swallow errors */ });
|
||||||
});
|
});
|
||||||
|
|
||||||
return Promise.all(promises).then(responses => {
|
return Promise.all(promises).then(responses => {
|
||||||
responses = responses.filter(obj => obj && obj.response.ok);
|
return responses.filter(obj => obj?.config);
|
||||||
return Promise.all(responses.map(obj => {
|
|
||||||
return {
|
|
||||||
url: obj.url,
|
|
||||||
config: obj.response.json()
|
|
||||||
};
|
|
||||||
}));
|
|
||||||
}).then(configs => {
|
}).then(configs => {
|
||||||
const selection = configs.find(obj => !obj.config.StartupWizardCompleted) || configs[0];
|
const selection = configs.find(obj => !obj.config.StartupWizardCompleted) || configs[0];
|
||||||
return Promise.resolve(selection?.url);
|
return selection?.url;
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
return Promise.resolve();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue