From a0751994b137063309aa77b4a053099c95ee384c Mon Sep 17 00:00:00 2001 From: Mckay Wrigley Date: Mon, 20 Mar 2023 04:30:18 -0600 Subject: [PATCH] api key fix --- pages/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index 0f1de47..52c588c 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -217,7 +217,7 @@ export default function Home() { localStorage.setItem("apiKey", apiKey); }; - const fetchModels = async () => { + const fetchModels = async (key: string) => { setLoading(true); const response = await fetch("/api/models", { @@ -226,7 +226,7 @@ export default function Home() { "Content-Type": "application/json" }, body: JSON.stringify({ - key: apiKey + key }) }); const data = await response.json(); @@ -244,7 +244,7 @@ export default function Home() { setLightMode(theme as "dark" | "light"); } - const apiKey = localStorage.getItem("apiKey"); + const apiKey = localStorage.getItem("apiKey") || ""; if (apiKey) { setApiKey(apiKey); } @@ -274,7 +274,7 @@ export default function Home() { }); } - fetchModels(); + fetchModels(apiKey); }, []); return (