So the state is an object
{
btx_mxn: // one value
btx_usd: // another value
}
The values for those seem to be objects, so it looks something like
{
btx_mxn: {high: "222500.00", last: "207544.24", created_at: "2020-05-21T23:51:49+00:00", book: "btc_mxn", volume: "569.34086668"},
btx_usd: {high: "222500.00", last: "207544.24", created_at: "2020-05-21T23:51:49+00:00", book: "btc_mxn", volume: "569.34086668"},
}
React doesn’t do anything special here, it just works like JS, because it is JS. You access objects as you would anywhere else in JS, and that’s what you aren’t doing.
This, then, doesn’t seem to be correct:
class BitsoApi extends React.Component{
state = {
btc_mxn: [],
btc_usd:[]
};
You are saying they are arrays when AFAICS they aren’t (please correct me if I’m wrong)
So as a simplified example (this is not complete, you’ll need to do a bit more work):
So you can write a component (this is exactly equivalent to what you’re doing with the display bit of the code, but it’s generally easier to split the logic down). It will be a list item. I’ll just pull out two of the values, I don’t know how you want to display this data. I’m just using made-up names as well, call it something better:
function BtxItem (btxItem) {
return (
<li>
<p>High: {btxItem.high}</p>
<p>Last: {btxItem.last}</p>
</li>
);
}
If you give that function one of the results, it will create a list item that renders the values I’ve said it should render.
Then in your main component, you want to render a list item for each result:
class BitsoApi extends React.Component{
state = {
btc_mxn: null,
btc_usd: null,
};
// rest of the logic to get the data here
render() {
return (
<ul>
{ Object.values(this.state).map((item) => <BtxItem btxItem={item} />) }
</ul>
);
}
}
Do you see how this hangs together?