api key fix
This commit is contained in:
parent
ff1d36f642
commit
a0751994b1
|
@ -217,7 +217,7 @@ export default function Home() {
|
||||||
localStorage.setItem("apiKey", apiKey);
|
localStorage.setItem("apiKey", apiKey);
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchModels = async () => {
|
const fetchModels = async (key: string) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
const response = await fetch("/api/models", {
|
const response = await fetch("/api/models", {
|
||||||
|
@ -226,7 +226,7 @@ export default function Home() {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
key: apiKey
|
key
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
@ -244,7 +244,7 @@ export default function Home() {
|
||||||
setLightMode(theme as "dark" | "light");
|
setLightMode(theme as "dark" | "light");
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiKey = localStorage.getItem("apiKey");
|
const apiKey = localStorage.getItem("apiKey") || "";
|
||||||
if (apiKey) {
|
if (apiKey) {
|
||||||
setApiKey(apiKey);
|
setApiKey(apiKey);
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ export default function Home() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchModels();
|
fetchModels(apiKey);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue