ChatGPT Course – Use The OpenAI API to Code 5 Projects

I’m watching Ania’s chatgpt YT video and I can’t seem to get the code working. I’m fairly certain I have the correct code. But the response variable in the fetchData function says " response’ is declared but it’s value is never read"
Watch 16 min into her video the code how it looks like on her end. Below is my code. Her code worked on the video but mine did not. What did I miss here? (not including my api key below.)

async function fetchData(){
    const response = await fetch("",{
        method: "POST",
        Authorization: `Bearer ${API_KEY}`,
        "Content-Type": "application/json"
    body: JSON.stringify({
        model: "text-davinci-003", 
        prompt: "hello, how are you today?", 
        max_tokens: 7,
    } )

const data = await response.json();


You’re accessing response outside of your fetchData function.

1 Like

OMG. Thank you. I see it now. Much appreciate your help @nhcarrigan