From 3b4dace1aaf8590bd632da208e554d24c611bbea Mon Sep 17 00:00:00 2001 From: ltctceplrm <14954927+ltctceplrm@users.noreply.github.com> Date: Tue, 23 Sep 2025 00:01:11 +0200 Subject: [PATCH] Fixed potential bug in openlibrary Specifically TypeError: Cannot read properties of undefined (reading 'toString') --- src/api/apis/OpenLibraryAPI.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/apis/OpenLibraryAPI.ts b/src/api/apis/OpenLibraryAPI.ts index c39faa5..d5c041e 100644 --- a/src/api/apis/OpenLibraryAPI.ts +++ b/src/api/apis/OpenLibraryAPI.ts @@ -66,7 +66,7 @@ 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(', '), @@ -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,