Hello I have made a simple AXIOS get request and receive an array of objects. But the example I used to achieve this returns all array at one and I need to separate the objects so I could use each of them separately.
class apitest extends Component {
constructor(props) {
super(props);
this.state = {
cryptos: []
};
}
componentDidMount() {
axios
.get(
"https://min-api.cryptocompare.com/data/pricemulti?fsyms=BTC,ETH,XRP,BCH,EOS,TRX&tsyms=EUR,CHANGE&api_key=xxx"
)
.then(res => {
const cryptos = res.data;
console.log(cryptos);
this.setState({ cryptos: cryptos});
});
}
render() {
return (
<div className="test">
{Object.keys(this.state.cryptos).map(key => (
<div id="crypto-container">
<span className="left">{key}</span>
<span className="right">
<NumberFormat
value={this.state.cryptos[key].EUR}
displayType={"text"}
decimalPrecision={2}
thousandSeparator={true}
prefix={"€"}
/>
</span>
</div>
))}
</div>
);
}
}
export default apitest;