Answers for "where to call api in react"

0

react api call

How to fetch data from api Examples with typescript

     const [data, setData] = useState([])
    const [error, setError] = useState('')

    useEffect(() => {
        axios.get('http://localhost:4000/superheroes')
        .then((_res:any) => {
            console.log(_res.data);
            setData(_res.data)
          
        })
        .catch(error => {
          setError(error.message)
          
        })

      }, [])
Posted by: Guest on October-22-2021
0

react api call

map function
{Terms?.item?.map((item)=>{
return <div key={item.title}>{item.title}</div>
})}
Posted by: Guest on October-22-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language