How could I display data from a json
file using reactjs
.
I would like to display a specific value on my website using a json
file.
Using this example json
file.
const data = [
{
items: {
item: [
{
id: "0001",
type: "donut",
name: "Cake",
ppu: 0.55,
batters: {
batter: [
{
id: "377",
type: "Regular",
},
{
id: "609",
type: "Chocolate",
},
{
id: "788",
type: "Blueberry",
},
{
id: "809",
type: "Devil's Food",
},
],
},
topping: [
{
id: "5001",
type: "None",
},
{
id: "5002",
type: "Glazed",
},
{
id: "5005",
type: "Sugar",
},
{
id: "5007",
type: "Powdered Sugar",
},
{
id: "5006",
type: "Chocolate with Sprinkles",
},
{
id: "5003",
type: "Chocolate",
},
{
id: "5004",
type: "Maple",
},
],
},
],
},
},
];
How could I access for example items.item.batters.batter
for id 609
and display the type
in this case "Chocolate"
using reactjs
without using something like this:
batters.batter[1].type
and instead displaying it for the specific id
(609
)?