typescript-typenfehler behoben.. npm run lint läuft nun fehlerfrei durch.
This commit is contained in:
@@ -40,8 +40,9 @@ async function handleResponse<T>(response: Response): Promise<T> {
|
||||
const data = await response.json().catch(() => null);
|
||||
|
||||
if (!response.ok) {
|
||||
const error = new Error((data && data.error && data.error.message) || 'Request failed');
|
||||
(error as any).code = data?.error?.code ?? response.status;
|
||||
const errorPayload = data as { error?: { message?: string; code?: unknown } } | null;
|
||||
const error = new Error(errorPayload?.error?.message ?? 'Request failed') as Error & { code?: unknown };
|
||||
error.code = errorPayload?.error?.code ?? response.status;
|
||||
throw error;
|
||||
}
|
||||
|
||||
@@ -78,4 +79,3 @@ export async function fetchGalleryPhotos(token: string, cursor?: string | null,
|
||||
|
||||
return handleResponse<GalleryPhotosResponse>(response);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user