I was making a web app that can generate essay but it seems i am encountering this error POST https://cors-anywhere.herokuapp.com/https://api.openai.com/v1/text-davinci/questions 404 (Not Found) sendTopicAndWordCount @ index.html:24 onclick @ index.html:13
This is the code `<!DOCTYPE html>
<html>
<head>
<title>Essay Generator</title>
</head>
<body>
<h1>Essay Generator</h1>
<form>
<label for="topic">Topic:</label><br>
<input type="text" id="topic" name="topic"><br>
<label for="wordCount">Word Count:</label><br>
<input type="number" id="wordCount" name="wordCount"><br><br>
<button type="button" onclick="sendTopicAndWordCount()">Generate Essay</button>
</form>
<div id="response"></div>
<script>
function sendTopicAndWordCount() {
// Get the topic and word count from the form
var topic = document.getElementById("topic").value;
var wordCount = document.getElementById("wordCount").value;
// Make the API request using a CORS proxy
fetch("https://cors-anywhere.herokuapp.com/https://api.openai.com/v1/text-davinci/questions", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer api key"
},
body: JSON.stringify({
"prompt": "Write a essay on " + topic,
"max_tokens": wordCount
})
})
.then(response => response.json())
.then(response => {
// Display the API's response in the div
document.getElementById("response").innerHTML = response.text;
});
}
</script>
</body>
</html>`