Fixed potential bug in openlibrary

Specifically TypeError: Cannot read properties of undefined (reading 'toString')
This commit is contained in:
ltctceplrm 2025-09-23 00:01:11 +02:00
parent 813c165b88
commit 3b4dace1aa

View file

@ -66,7 +66,7 @@ export class OpenLibraryAPI extends APIModel {
new BookModel({ new BookModel({
title: result.title, title: result.title,
englishTitle: result.title, englishTitle: result.title,
year: result.first_publish_year.toString(), year: result.first_publish_year?.toString() ?? 'unknown',
dataSource: this.apiName, dataSource: this.apiName,
id: result.key, 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({ return new BookModel({
title: result.title, title: result.title,
year: result.first_publish_year.toString(), year: result.first_publish_year?.toString() ?? 'unknown',
dataSource: this.apiName, dataSource: this.apiName,
url: `https://openlibrary.org` + result.key, url: `https://openlibrary.org` + result.key,
id: result.key, id: result.key,