From 07882089fb28ae953f2e4c4163532e85ea4b411b Mon Sep 17 00:00:00 2001 From: Futa Ikeda Date: Mon, 28 Aug 2023 21:41:27 -0400 Subject: [PATCH] Handle case where links object is not there --- app/models/index-card-search.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/index-card-search.ts b/app/models/index-card-search.ts index da7f647128..103cf169dd 100644 --- a/app/models/index-card-search.ts +++ b/app/models/index-card-search.ts @@ -23,7 +23,7 @@ export default class IndexCardSearchModel extends Model { relatedProperties!: RelatedPropertyPathModel[]; get firstPageCursor() { - if (this.searchResultPage.links.first?.href) { + if (this.searchResultPage.links?.first?.href) { const firstPageLinkUrl = new URL(this.searchResultPage.links.first?.href); return firstPageLinkUrl.searchParams.get('page[cursor]'); } @@ -31,7 +31,7 @@ export default class IndexCardSearchModel extends Model { } get prevPageCursor() { - if (this.searchResultPage.links.prev?.href) { + if (this.searchResultPage.links?.prev?.href) { const prevPageLinkUrl = new URL(this.searchResultPage.links.prev?.href); return prevPageLinkUrl.searchParams.get('page[cursor]'); } @@ -39,7 +39,7 @@ export default class IndexCardSearchModel extends Model { } get nextPageCursor() { - if (this.searchResultPage.links.next?.href) { + if (this.searchResultPage.links?.next?.href) { const nextPageLinkUrl = new URL(this.searchResultPage.links.next?.href); return nextPageLinkUrl.searchParams.get('page[cursor]'); }