From daa4df07ce00f196fd3abfbdde6c9ee479db6858 Mon Sep 17 00:00:00 2001 From: Gamebrary Date: Mon, 24 May 2021 19:11:44 -0700 Subject: [PATCH] make platform filtering optional --- functions/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/index.js b/functions/index.js index 9b4575a4..4cdbb266 100755 --- a/functions/index.js +++ b/functions/index.js @@ -70,7 +70,7 @@ exports.search = functions.https.onRequest((req, res) => { const { search, platform, token } = req.query; - const missingFields = [search, platform, token].filter((field) => !field).length > 0; + const missingFields = [search, token].filter((field) => !field).length > 0; if (missingFields) { return res.status(400).json({ error: 'missing required params (search OR platform OR token)' }); @@ -80,7 +80,7 @@ exports.search = functions.https.onRequest((req, res) => { search "${search}"; fields id,name,slug,rating,release_dates.*,name,cover.image_id; limit 50; - where platforms = (${platform}); + ${platform ? `where platforms = (${platform});` : ''} ` axios({