i have the following structure. I need to get Internal value and through in the React. I think i need to get an array of values, for example: [\'Bitcoin\', \'Etherium\'...] and
Do it like this
import React from 'react'
export default class YourComponent extends React.Component {
render() {
let arr = [
{
"CoinInfo": {
"Id": "1182",
"Name": "BTC",
"FullName": "Bitcoin",
"Internal": "BTC",
"ImageUrl": "/media/19633/btc.png",
"Url": "/coins/btc/overview"
}
},
{
"CoinInfo": {
"Id": "7605",
"Name": "ETH",
"FullName": "Ethereum",
"Internal": "ETH",
"ImageUrl": "/media/20646/eth_logo.png",
"Url": "/coins/eth/overview"
}
}
]
let newArr = arr.map((data) => {
return data.CoinInfo.FullName
})
console.log('new array', newArr);
return (
<div>
</div>
)
}
}
Here's how you'd get an array of coin names using Array.prototype.map()
const arr = [{
"CoinInfo": {
"Id": "1182",
"Name": "BTC",
"FullName": "Bitcoin",
"Internal": "BTC",
"ImageUrl": "/media/19633/btc.png",
"Url": "/coins/btc/overview"
}
},
{
"CoinInfo": {
"Id": "7605",
"Name": "ETH",
"FullName": "Ethereum",
"Internal": "ETH",
"ImageUrl": "/media/20646/eth_logo.png",
"Url": "/coins/eth/overview"
}
}
];
const coinNames = arr.map(x => x.CoinInfo.FullName);
console.log(coinNames);