Answers for "call api 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
3

React get method

/* React get method.  */

componentWillMount(){
    fetch('/getcurrencylist',
    {
        /*
        headers: {
          'Content-Type': 'application/json',
          'Accept':'application/json'
        },
        */
        method: "get",
        dataType: 'json',
    })
    .then((res) => res.json())
    .then((data) => {
      var currencyList = [];
      for(var i=0; i< data.length; i++){
        var currency = data[i];
        currencyList.push(currency);
      }
      console.log(currencyList);
      this.setState({currencyList})
      console.log(this.state.currencyList);
    })
    .catch(err => console.log(err))
  }
Posted by: Guest on July-21-2020
0

react api call

;ksmclksamcklsc
Posted by: Guest on October-25-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