0

here is the my json data, i want to use "name" in products.

list:[ { id: 1, suppliercard:{ iduser: 5, supplier:{ product:[{name: "ment"}] } } } ]

here is my code

 list.map((item, index) => {
        return (
          <div key={index}>
            <ul >{item.id}</ul>
            item.suppliercard.supplier.product.map((subitem, i) => {
              return (
                 <p>{subitem.name}</p>
              )
            })
          </div>
        )
      })

it's not working

2
  • this should work... Commented Jan 10, 2018 at 14:29
  • Please edit... missing things like: what is it not working? what is the error that you get? etc. Commented Jan 10, 2018 at 14:32

1 Answer 1

1

You should wrap item.suppliercard.supplier.product.map in { } because it is not jsx but javascript that should be executed. Try this:

list.map((item, index) => {
      return (<div key={index}>
        <ul>{item.id}</ul>
        {
          item.suppliercard.supplier.product.map((subitem, i) => 
          (<p>{subitem.name}</p>)) 
        }
      </div>)
    })
Sign up to request clarification or add additional context in comments.

1 Comment

@mahigorige25, could you mark the answer as accepted if it solved your problem?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.