silent
April 22, 2023, 1:00am
1
hi, i tried to work through this course .
but i hang on first try of request.
i do provide a model parameter but it been not recognized.
What am I overlooking?
sure, i tried with a real api key - not “xxx”
thank you!
Edit:
app.js
const API_KEY = "■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■63xAcwDiUvU"
async function fetchDate() {
const response = await fetch("https://api.openai.com/v1/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${API_KEY}`,
"Contant-Type": "application/json"
},
body: JSON.stringify({
model: "text-davinci-003",
prompt: "hello, how are you today?",
max_tokens: 7
})
})
const data = await response.json()
console.log(data)
}
fetchDate()
index.html
<!DOCTYPE html>
<html leng="en">
<head>
<meta charset="UTF-8"
<title>My App</title>
</head>
<body>
<script src="app.js"></script>
</body>
</html>
Might be a syntax error in the json, it sometimes gives me this error when I have a mistake in my structure.
silent
April 22, 2023, 2:39am
3
Maybe someone will see this error and could help.
silent
April 23, 2023, 8:05pm
4
Is there anyone here who can see the error in the code or in the syntax?
i don’t get it running
Maybe it would be easier to find some error in the code or syntax if people could read the code. An image with 1/3 of the code I suppose is not helpful - but it is just a supposition.
silent
April 24, 2023, 6:01am
6
i thought that 100% of code is visible. i added it to the first post and hope it helps.^^
1 Like
there is a typo in the headers
section where
Content-Type
is misspelled as “Conta nt-Type” .
1 Like
silent
April 24, 2023, 6:33pm
8
really?? Oh damn. sorry and thank you alot!!
(this sentence is not enough as a answer?! got this error:
“An error occurred: Body seems unclear, is it a complete sentence?”)
welcome.
are you talking about this forum rules? yes, we must write.
Yes, no, ok, really - is not enough.
silent
April 24, 2023, 10:45pm
10
So it’s only about the first one-word-sentence (really??) and not the total amount of text?
I can’t remember the exact number, but I think it is a minimum of 25 characters.
silent
April 25, 2023, 4:59pm
12
even 43 characters were not enough
(“So it’s only about the first sentence and not the total amount?”)
There are user levels in this forum - all these rules and restrictions become suggestions after some levels, badges, activities, etc.