fix: make search usable again
This commit is contained in:
@@ -31,6 +31,9 @@ const cacheLock = new Map<string, Promise<Resource>>();
|
||||
|
||||
async function fetchAndStoreUrl(url: string) {
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch resource: ${response.status}`);
|
||||
}
|
||||
const res = await response.json();
|
||||
fetchCache.set(url, res);
|
||||
return res;
|
||||
@@ -54,7 +57,7 @@ async function cachedFetch(
|
||||
return res;
|
||||
}
|
||||
|
||||
export async function fetchResource<T extends Resource>(
|
||||
export async function fetchResource<T extends GenericResource>(
|
||||
resource: string,
|
||||
): Promise<T | undefined> {
|
||||
try {
|
||||
@@ -80,6 +83,7 @@ export async function listResources<T extends GenericResource>(
|
||||
.map((res) => addImageToResource(res) as Promise<T>),
|
||||
);
|
||||
} catch (_e) {
|
||||
console.log(`Failed to fetch resource: ${resource}`, _e);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user