How to get data objects with app.request.get?

Hi,

This is json data.

[
  {
    "id": 1,
    "title": {
      "rendered": "Audio Technica"
    },
    "content": {
      "rendered": "<p>Looking for comfortable to wear headphones</p>",
    },     
  }
]

I can do this to get variables in jquery.

$.ajax({
	type:"get",
	url:"post.json",
	success: function(data){
		var post = data[0];
		var title = post.title.rendered;
		var content = post.content.rendered;
		console.log(title);
	}
});

But similar method is not working with app.request.get

app.request.get('post.json', function (data) {
    var post = data[0];
    var title = post.title.rendered;
    console.log(title);
});

It show “Uncaught TypeError: rendered undefined” message in console.log. If i try to get “id” then it shows just undefined message. But when i add console.log(data) then it works fine and show the whole data from json file. What am i doing wrong? and how can i get it right?

Thanks

Number 1 : i think ur json must be like this

    [
      {
        "id": 1,
        "title": {
          "rendered": "Audio Technica"
        },
        "content": {
          "rendered": "<p>Looking for comfortable to wear headphones</p>"
        }     
      }
    ]

and Number 2

	success: function(data)
    {
		var obj = JSON.parse(data);
        console.log(obj)
    }

CMIIW :wink: