Handle potentially missing fields for OpenLibraryAPI
This commit is contained in:
parent
23b5ee0ef9
commit
0e729e59d3
1 changed files with 4 additions and 4 deletions
|
|
@ -66,10 +66,10 @@ 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,
|
||||||
|
|
@ -119,7 +119,7 @@ export class OpenLibraryAPI extends APIModel {
|
||||||
isbn13: Number.isNaN(isbn13) ? undefined : isbn13,
|
isbn13: Number.isNaN(isbn13) ? undefined : isbn13,
|
||||||
englishTitle: result.title,
|
englishTitle: result.title,
|
||||||
|
|
||||||
author: result.author_name.join(', '),
|
author: result.author_name?.join(', '),
|
||||||
pages: Number.isNaN(pages) ? undefined : pages,
|
pages: Number.isNaN(pages) ? undefined : pages,
|
||||||
onlineRating: result.ratings_average,
|
onlineRating: result.ratings_average,
|
||||||
image: result.cover_edition_key ? `https://covers.openlibrary.org/b/OLID/` + result.cover_edition_key + `-L.jpg` : undefined,
|
image: result.cover_edition_key ? `https://covers.openlibrary.org/b/OLID/` + result.cover_edition_key + `-L.jpg` : undefined,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue