import Head from "next/head"; import { useState } from "react"; import styles from "./index.module.css"; export default function Home() { const [animalInput, setAnimalInput] = useState(""); const [result, setResult] = useState(); async function onSubmit(event) { event.preventDefault(); const response = await fetch("/api/generate", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ animal: animalInput }), }); const data = await response.json(); setResult(data.result); setAnimalInput(""); } return (
OpenAI Quickstart

Name my pet

setAnimalInput(e.target.value)} />
{result}
); }