Learning React and I was wondering how could I iterate through a dictionary. I come from python and theres a .items() method that can return key and value...is there a similar function in React? I want to set the values into a const and store them for future use. Heres what I have so far. (The reason I need this is because my JSON response gives an array which I already iterated through, but then a dictionary which I need to of course pull values from). Thanks so much for your time. Any response helps :)
JSX:
function Home(){
const [data, setData] = useState();
const getData= ()=>{
fetch('http://localhost:8070/api')
.then(function(response){
return response.json();
})
.then(function(myJson){
console.log(myJson);
setData(myJson)
})
}
useEffect(()=>{
getData()
},[])
return (
<div className="Home">
{
data?.results.map(result =>(
<p class="text-nowrap bd-highlight" style={{width: "8rem"}}>{JSON.stringify(result.items)}</p> // HERES THE DICTIONARY
))
}
</div>
)
}