Answers for "reactjs useeffect async await then return"

0

async in useeffect

function myApp() {
  const [data, setdata] = useState()

  useEffect(() => {
    async function fetchMyAPI() {
      const response = await fetch('api/data')
      response = await response.json()
      setdata(response)
    }

    fetchMyAPI()
  }, [])
}
Posted by: Guest on June-05-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language