'Iterate through JSON File in Javascript

I want to work with an JSON File in Javascript I got from my Flask server via a Axios Get-Request.

Its build like this:

{
  "data": [
    {
      "item": "[224,4,1,80,207,137,153,132]", 
      "name": "A1"
    }, 
    {
      "item": "[224,4,1,80,207,137,153,136]", 
      "name": "A2"
    }, 
    {
      "item": "[224,4,1,80,207,137,157,190]", 
      "name": "A3"
    }
  ]
}

I make my request with this and I can see the output in the terminal:

getInitialBoxesA() {
      const path = 'http://localhost:5000/getAllBoxesA';
      axios.get(path)
        .then((res) => {
          console.log(res.data);
        })
        .catch((error) => {
          // eslint-disable-next-line
          console.error(error);
        });
    },

How can i iterate through this Array in Javascript?

I tried res.data[0] or res.data[0].item



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source