chore: fix typescript with optional return from api call

This commit is contained in:
Lei Nelissen
2024-07-21 22:30:06 +02:00
parent 68c8808188
commit e0177fb89b
5 changed files with 13 additions and 11 deletions

View File

@@ -52,8 +52,9 @@ export async function fetchApi<T>(
// Actually perform the request
const response = await fetch(url, config);
if (__DEV__) {
console.log(`[HTTP][${response.status}]`, url, config);
if (__DEV__) {
console.log(`%c[HTTP][${response.status}] ${url}`, 'font-weight:bold;');
console.log('\t', config);
}
// GUARD: Check if the response is as expected
@@ -88,7 +89,8 @@ export async function fetchApi<T>(
*/
export function getImage(ItemId: string): string {
const credentials = asyncFetchStore().getState().settings.jellyfin;
return encodeURI(`${credentials?.uri}/Items/${ItemId}/Images/Primary?format=jpeg`);
const uri = encodeURI(`${credentials?.uri}/Items/${ItemId}/Images/Primary?format=jpeg`);
return uri;
}
/**