Skip to content

Commit 7f672d9

Browse files
authored
fix api key error not showing (#8)
1 parent 2f2ad7e commit 7f672d9

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

app/lib/getHtmlFromOpenAI.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ export async function getHtmlFromOpenAI({
5555
}
5656

5757
let json = null
58+
if (!apiKey) {
59+
throw Error('You need to provide an API key (sorry)')
60+
}
5861
try {
59-
if (!apiKey) {
60-
throw Error('You need to provide an API key (sorry)')
61-
}
62-
6362
const resp = await fetch('https://api.openai.com/v1/chat/completions', {
6463
method: 'POST',
6564
headers: {
@@ -74,8 +73,6 @@ export async function getHtmlFromOpenAI({
7473
console.log(e)
7574
}
7675

77-
78-
7976
return json
8077
}
8178

0 commit comments

Comments
 (0)