Skip to content

Commit 3b4dace

Browse files
committed
Fixed potential bug in openlibrary
Specifically TypeError: Cannot read properties of undefined (reading 'toString')
1 parent 813c165 commit 3b4dace

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/api/apis/OpenLibraryAPI.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class OpenLibraryAPI extends APIModel {
6666
new BookModel({
6767
title: result.title,
6868
englishTitle: result.title,
69-
year: result.first_publish_year.toString(),
69+
year: result.first_publish_year?.toString() ?? 'unknown',
7070
dataSource: this.apiName,
7171
id: result.key,
7272
author: result.author_name.join(', '),
@@ -111,7 +111,7 @@ export class OpenLibraryAPI extends APIModel {
111111

112112
return new BookModel({
113113
title: result.title,
114-
year: result.first_publish_year.toString(),
114+
year: result.first_publish_year?.toString() ?? 'unknown',
115115
dataSource: this.apiName,
116116
url: `https://openlibrary.org` + result.key,
117117
id: result.key,

0 commit comments

Comments
 (0)