I have an array in JSON:
[
{
"id": 0,
"type": "phone",
"model": "Iphone 11"
},
{
"id": 1,
"type": "phone",
"model": "Iphone 11 PRO"
}
]
I have an 'axios' request :
const [phone,setPhone] = useState({}) // react-hook
const getPhones = () => {
Axios.get('/phones.json').then(({data}) => {
setPhone(data)
console.log(data)
})
}
So I want to show, for example 'type' and 'model' from 1st and 2d objects? How i can do it?
It doesn't work
<div>
<div>{phone.type}</div>
<button onClick={getPhones}>click</button>
</div>