Skip to content

Commit

Permalink
fix: no exception
Browse files Browse the repository at this point in the history
  • Loading branch information
sznowicki authored Dec 26, 2023
1 parent e939553 commit dd52674
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand All @@ -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;
Expand Down

0 comments on commit dd52674

Please sign in to comment.