Axios v0.26.1 promise based HTTP client used to get crypto prices from axternal API.
💾 Setup
API does not require an API key.
npm start Runs the app in the development mode. Open http://localhost:3000 to view it in the browser.
npm run build Builds the app for production to the build folder. It correctly bundles React in production mode and optimizes the build for the best performance. The build is minified and the filenames include the hashes.
💻 Code Examples
extract of App.js - axios http asynchronous call to cryptocurrency API.
/*function will be carried out once app loadsaxios is promise-based so then function usedcryptocompare returns price of 3 bitcoins compared to the US $.*/componentDidMount(){constfsymsList='BTC,XRP,BCH,ETH,ZEC,EOS,XMR,ETC,LTC,DASH,QTUM,NEO,XLM,TRX,ADA,BTS,USDT,XUC,PAX,IOT'axios.get('https://min-api.cryptocompare.com/data/pricemulti?fsyms='+fsymsList+'&tsyms=USD').then(res=>{constcryptos=res.data;console.log(cryptos);this.setState({cryptos: cryptos});});}