Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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()
  }, [])
}
Source by ultimatecourses.com #
 
PREVIOUS NEXT
Tagged: #async #useeffect
ADD COMMENT
Topic
Name
9+8 =