From 0e729e59d31d317141d3955f92f461c398452a00 Mon Sep 17 00:00:00 2001 From: ltctceplrm <14954927+ltctceplrm@users.noreply.github.com> Date: Sat, 25 Oct 2025 14:16:13 +0200 Subject: [PATCH] Handle potentially missing fields for OpenLibraryAPI --- src/api/apis/OpenLibraryAPI.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/apis/OpenLibraryAPI.ts b/src/api/apis/OpenLibraryAPI.ts index c39faa5..e3590a0 100644 --- a/src/api/apis/OpenLibraryAPI.ts +++ b/src/api/apis/OpenLibraryAPI.ts @@ -66,10 +66,10 @@ export class OpenLibraryAPI extends APIModel { new BookModel({ title: result.title, englishTitle: result.title, - year: result.first_publish_year.toString(), + year: result.first_publish_year?.toString() ?? 'unknown', dataSource: this.apiName, id: result.key, - author: result.author_name.join(', '), + author: result.author_name?.join(', '), }), ); } @@ -111,7 +111,7 @@ export class OpenLibraryAPI extends APIModel { return new BookModel({ title: result.title, - year: result.first_publish_year.toString(), + year: result.first_publish_year?.toString() ?? 'unknown', dataSource: this.apiName, url: `https://openlibrary.org` + result.key, id: result.key, @@ -119,7 +119,7 @@ export class OpenLibraryAPI extends APIModel { isbn13: Number.isNaN(isbn13) ? undefined : isbn13, englishTitle: result.title, - author: result.author_name.join(', '), + author: result.author_name?.join(', '), pages: Number.isNaN(pages) ? undefined : pages, onlineRating: result.ratings_average, image: result.cover_edition_key ? `https://covers.openlibrary.org/b/OLID/` + result.cover_edition_key + `-L.jpg` : undefined,