From d47746cf76599280cc3d82e8f3de8a021f7b5b7e Mon Sep 17 00:00:00 2001 From: azuki774s Date: Sat, 1 Mar 2025 21:51:21 +0900 Subject: [PATCH] skip call API if yyyymm=null --- components/SearchHistory.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/SearchHistory.vue b/components/SearchHistory.vue index c54916c..5c6ace5 100644 --- a/components/SearchHistory.vue +++ b/components/SearchHistory.vue @@ -63,14 +63,19 @@ onMounted(async () => { const fetchData = async (yyyymm: string, categoryID: string) => { try { - let query = `?yyyymm=${yyyymm}` + if (yyyymm == null) { + // パラメータが不正なときは何もしない + return + } + let query = `?yyyymm=${yyyymm}` // categoryID が null または undefined の場合、'-1' に置き換える const validCategoryID = categoryID ? categoryID : '-1' if (validCategoryID == '-1') { // パラメータが不正なときは何もしない return } + if (categoryID != '0') { // 0 = 全カテゴリ query += `&category_id=${validCategoryID}`