Answers for "api request 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
0

react api call

API Store Page Examples with typescript
 const [item, setItem] = useState([] as any[])

  useEffect(() => {
    getTerms()
  }, [])

  const getTerms = ()=> {
    TermService.getDescription()
      .then((_res:any) => {
        console.log(_res.data.data.information,"++++++")
        setItem(_res.data.data.information)
      })
      .catch((err) => {
        console.log(err)
      })
  }
Posted by: Guest on October-22-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language