better error handling in api

This commit is contained in:
CyferShepard
2024-09-16 08:51:59 +02:00
parent 92ba211e8b
commit b455d7614b
2 changed files with 20 additions and 4 deletions

View File

@@ -109,7 +109,7 @@ class EmbyAPI {
return response?.data || [];
}
console.log(response?.data || response);
console.log("[JELLYFIN-API] : getUsers - " + (response?.data || response));
return [];
} catch (error) {
@@ -355,12 +355,20 @@ class EmbyAPI {
if (!userid || userid == null) {
let adminid = await new configClass().getPreferedAdmin();
if (!adminid || adminid == null) {
userid = (await this.getAdmins())[0].Id;
const admins = await this.getAdmins();
if (admins.length > 0) {
userid = admins[0].Id;
}
} else {
userid = adminid;
}
}
if (!userid || userid == null) {
console.log("[JELLYFIN-API]: getRecentlyAdded - No Admins/UserIds found");
return [];
}
let url = `${this.config.JF_HOST}/Users/${userid}/Items/Latest?Limit=${limit}`;
if (libraryid && libraryid != null) {

View File

@@ -108,7 +108,7 @@ class JellyfinAPI {
return response?.data || [];
}
console.log(response?.data || response);
console.log("[JELLYFIN-API] : getUsers - " + (response?.data || response));
return [];
} catch (error) {
@@ -352,12 +352,20 @@ class JellyfinAPI {
if (!userid || userid == null) {
let adminid = await new configClass().getPreferedAdmin();
if (!adminid || adminid == null) {
userid = (await this.getAdmins())[0].Id;
const admins = await this.getAdmins();
if (admins.length > 0) {
userid = admins[0].Id;
}
} else {
userid = adminid;
}
}
if (!userid || userid == null) {
console.log("[JELLYFIN-API]: getRecentlyAdded - No Admins/UserIds found");
return [];
}
let url = `${this.config.JF_HOST}/Users/${userid}/Items/Latest?Limit=${limit}`;
if (libraryid && libraryid != null) {