nsarrazin's picture
nsarrazin HF staff
Refactor of websearch (#281)
6434339 unverified
raw
history blame
446 Bytes
import { SERPAPI_KEY } from "$env/static/private";
import { getJson } from "serpapi";
import type { GoogleParameters } from "serpapi";
// Show result as JSON
export async function searchWeb(query: string) {
const params = {
q: query,
hl: "en",
gl: "us",
google_domain: "google.com",
api_key: SERPAPI_KEY,
} satisfies GoogleParameters;
// Show result as JSON
const response = await getJson("google", params);
return response;
}