0

Here is fiddle with code: jsfiddle

{
  "status": {
    "success": true,
    "error": ""
  },
  "data": {
    "item": [
      {
        "name": "Test 1",
        "keywords": [
          "[asdad,dasdas]"
        ],
        "description": "xxzfrfa",
        "test": 12.3,
        "id": "584ab61344be2bd806ef276d"
      },
      {
        "name": "My test 2",
        "keywords": [
          "[zx,zz]"
        ],
        "description": "xz",
        "test": 53,
        "id": "584ab67b11b75c3a10fc1518"
      }
    ]
  }
}

...

<div id="product-container"></div>
<script id="product-template" type="text/x-handlebars-template">
    {{#each data.item}} 
        <h2>{{brand}}</h2>
    {{/each}}
</script>

What can I do to return data from JSON ?..it's not working now.. If anyone can help me. I've tried a lot of things.

jean-max
  • 1,640
  • 1
  • 18
  • 33

2 Answers2

0

The code you provided is working, there is nothing to render since there is no brand field.

Here is working example: https://jsfiddle.net/panamaprophet/nbn39wzu/

(since i didnt found a brand field in your example, i replaced it with name just for demonstration).

Panama Prophet
  • 1,027
  • 6
  • 6
0

You can access the name of an item like below

{{#data.item}} 
    <h2>{{name}}</h2>
{{/data.item}}

Sample code below: (Removed ajax to get it working here)

Fiddle

Sandeep Nayak
  • 4,649
  • 1
  • 22
  • 33