Getting this 429 error while using the gpt api while coding with javaScript can any one help me out in this

const generateResponse = () =>{
const API_URL =“”;

const requestOptions ={
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        "Authorization": `Bearer ${API_KEY}`
    },
    body: JSON.stringify({
        model: "gpt-3.5-turbo",
        messages: [{role: "user", content: userMessage}],
    })
}
fetch(API_URL, requestOptions).then(res => res.json()).then(data =>{
    console.log(data);
}).catch((error)=>{
    console.log(error)

})

}
I have this code and getting 429 erorr how can i have resolve this
script.js:31

   POST https://api.openai.com/v1/chat/completions 429 (Too Many Requests)

generateResponse @ script.js:31
(anonymous) @ script.js:54
setTimeout
handleChat @ script.js:52Understand this error
script.js:39 TypeError: Cannot read properties of undefined (reading ‘0’)
at script.js:34:44