Add fallback for missing rating
parent
7dcb49c6a5
commit
f7dc174e61
|
@ -173,9 +173,9 @@ export default class Thread {
|
||||||
private parseRating(data: TJsonLD): TRating {
|
private parseRating(data: TJsonLD): TRating {
|
||||||
const ratingTree = data["aggregateRating"] as TJsonLD;
|
const ratingTree = data["aggregateRating"] as TJsonLD;
|
||||||
const rating: TRating = {
|
const rating: TRating = {
|
||||||
average: parseFloat(ratingTree["ratingValue"] as string),
|
average: ratingTree ? parseFloat(ratingTree["ratingValue"] as string) : 0,
|
||||||
best: parseInt(ratingTree["bestRating"] as string),
|
best: ratingTree ? parseInt(ratingTree["bestRating"] as string) : 0,
|
||||||
count: parseInt(ratingTree["ratingCount"] as string),
|
count: ratingTree ? parseInt(ratingTree["ratingCount"] as string) : 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
return rating;
|
return rating;
|
||||||
|
|
Loading…
Reference in New Issue