Monday, 29 May 2017

extract parent node from array

I have an array like the one below and I want to be able to extract the parent then list the child

"options" : {
    "milk" : [ {
      "price" : 0,
      "title" : "Regular"
    }, {
      "price" : 0,
      "title" : "Soy"
    } ],
    "sugar" : [ {
      "price" : 0,
      "title" : 0
    }, {
      "price" : 0,
      "title" : 1
    } ]

so that I can display Milk - Regular, 0 - Soy, 0 Sugar - 0,0 - 1,0

I have been able to pass this.props.data.options.milk which allows for the title/price to be render but would like to loop over the options and render what they are and the prices

Thanks



via Paul 'Whippet' McGuane

No comments:

Post a Comment