From dd526745ff2d2332c28d3eb606386e8b268faa70 Mon Sep 17 00:00:00 2001 From: Szymon Nowicki Date: Tue, 26 Dec 2023 19:11:26 +0100 Subject: [PATCH] fix: no exception --- functions/index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/functions/index.js b/functions/index.js index f09754b..bc24096 100644 --- a/functions/index.js +++ b/functions/index.js @@ -9,6 +9,10 @@ import {trackQuery} from '../lib/mongo.js'; export const onRequestGet = async (context) => { const startTime = Date.now(); + const { request, env } = context; + const { searchParams } = new URL(request.url); + const { q} = Object.fromEntries(searchParams.entries()); + const { q: searchQuery, lang } = parseQuery(q); // Save used queries for analytics if (q) { trackQuery(context.env, { q, hasResults }) @@ -17,11 +21,6 @@ export const onRequestGet = async (context) => { }); } - const { request, env } = context; - const { searchParams } = new URL(request.url); - const { q} = Object.fromEntries(searchParams.entries()); - const { q: searchQuery, lang } = parseQuery(q); - const searchTimeStamp = Date.now(); const result = q ? await search(env, searchQuery, lang) : null; const doneIn = Date.now() - searchTimeStamp;