function Example() {
const [data, dataSet] = useState<any>(null)
useEffect(() => {
async function fetchMyAPI() { // make a new async function with a function name
let response = await fetch('api/data')
response = await response.json()
dataSet(response)
}
fetchMyAPI() // call the unction inside the useEffect()
}, [])
return <div>{JSON.stringify(data)}</div>
}