0

I'm trying to call api every 30 seconds. I already tried to do it with setInterval but it did not really work out.

Any suggestions?

 componentDidMount() {
        const {getCurrencies, setPageCount,loadData} = this.props.actions
         agent
            .get('https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?CMC_PRO_API_KEY=XXX')
            .then(res => {
                getCurrencies(res.body.data)
                setPageCount()
            })
            .catch(err => {
                console.log(err)
            });
    }
Nika Roffy
  • 891
  • 2
  • 8
  • 20
  • What do you mean by "it did not really work out." `setInterval` should work for this use-case. – Vasanth Gopal Jul 28 '20 at 12:28
  • I was doing it but in the middle one of my friends said that's it dangerous to use setInterval because it would "eat my data storage" – Nika Roffy Jul 28 '20 at 12:29
  • `setInterval` is the way to go here - ask your friend to elaborate what "eating your data storage" means. – goto Jul 28 '20 at 12:33

0 Answers0