# ChatGPT request returning undefined

**URL:** <https://community.thunkable.com/t/chatgpt-request-returning-undefined/2780134>\
**Category:** Questions about Thunkable X\
**Tags:** ai\
**Created:** [January 12, 2024, 5:13pm UTC](https://community.thunkable.com/t/chatgpt-request-returning-undefined/2780134 "2024-01-12T17:13:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bschwartz25ev](https://avatars.discourse-cdn.com/v4/letter/b/f0a364/32.png) [@bschwartz25ev](https://community.thunkable.com/u/bschwartz25ev)\
**Post date:** [January 12, 2024, 5:13pm UTC](https://community.thunkable.com/t/chatgpt-request-returning-undefined/2780134/1 "2024-01-12T17:13:11Z")

</div>

With this code, my label just returns “undefined”. I don’t even think it’s going to OpenAI. I’ve also defined the API code in the Service. Here’s my code:

 ![Screenshot 2024-01-12 at 12.06.52 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/5/15524b23a8887cc5dd67be07912bd2b8bd15d680.png)

---

<div class="post-metadata">

**Author:** ![matt\_conroy](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/matt_conroy/32/150843_2.png) [@matt\_conroy](https://community.thunkable.com/u/matt_conroy)\
**Post date:** [January 12, 2024, 6:29pm UTC](https://community.thunkable.com/t/chatgpt-request-returning-undefined/2780134/2 "2024-01-12T18:29:58Z")

</div>

Hi @bschwartz25ev, welcome to Thunkable! 🎉

Be sure to check out our posts about [How to ask Great Questions v2.0](https://community.thunkable.com/t/how-to-ask-great-questions-v2-0/2689983/1) and our [Community Guidelines](https://community.thunkable.com/t/community-guidelines/78/8) as you get started.

The real reason for this error likely lives in your console. You’ll probably see a 4-- error from [https://api.openai.com/v1/chat/completions](https://api.openai.com/v1/chat/completions). Let us know what you see. You can find info on how to access your browser’s console [here](https://balsamiq.com/support/faqs/browserconsole/#:~:text=To%20open%20the%20developer%20console,(on%20Windows%2FLinux).).

---

<div class="post-metadata">

**Author:** ![bschwartz25ev](https://avatars.discourse-cdn.com/v4/letter/b/f0a364/32.png) [@bschwartz25ev](https://community.thunkable.com/u/bschwartz25ev)\
**Post date:** [January 12, 2024, 6:52pm UTC](https://community.thunkable.com/t/chatgpt-request-returning-undefined/2780134/3 "2024-01-12T18:52:57Z")

</div>

Hello. Thanks! My error was {  
“error”: {  
“message”: “You didn’t provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR\_KEY), or as the password field (with blank username) if you’re accessing the API from your browser and are prompted for a username and password. You can obtain an API key from [https://platform.openai.com/account/api-keys.](https://platform.openai.com/account/api-keys.)”,  
“type”: “invalid\_request\_error”,  
“param”: null,  
“code”: null  
}  
}  
I entered the key, though. On my end, it says "main.16d4bd70.js:1

```
   POST https://api.openai.com/v1/chat/completions 429 (Too Many Requests)", but I haven't sent a request in hours.

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [April 11, 2024, 6:53pm UTC](https://community.thunkable.com/t/chatgpt-request-returning-undefined/2780134/4 "2024-04-11T18:53:49Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
