Note that there are some explanatory texts on larger screens.

plurals
  1. POReading JSON Object returned from API REST
    text
    copied!<p>I'm feeling stupid asking the question, but I'm with it like 3 days ago... I built a php api rest, that returns a json encode info. The json that the api returns is correct, is something like that:</p> <pre><code>[ {"pk_user":"1","name":"George","surname":"Littlewolf","profile":"Game designer - Developer"}, {"pk_user":"2","name":"Anne","surname":"Carpenter","profile":"Developer"}, {"pk_user":"3","name":"John","surname":"Sullivan","profile":"Designer"}, {"pk_user":"4","name":"Judith","surname":"Lenders","profile":"Developer"}, {"pk_user":"5","name":"Jason","surname":"Middleton","profile":"Manager"} ] </code></pre> <p>After that, I'm creating a backbone front-end to attack the api. I have developed only one view, that reads the json I wrote above. I have one <strong>model (User)</strong> and one <strong>Collection (Users)</strong> where I'd like to save the info read from the json info.</p> <p>I'm going to put only the code of the render function of the view:</p> <pre><code>render: function() { var users = new Users(); users.fetch(); $.each(users['models'], function(i, item) { console.log(item); }); this.template = _.template(template, {users : users}); this.$el.html(this.template); return this; } </code></pre> <p>Now, the console returns only what you see in the next image:</p> <p><img src="https://i.stack.imgur.com/NmmYE.png" alt="enter image description here"></p> <p>I'd like to access directly to the items, but i don't know why but all that I've tried is notworking... Thanks and excuse me for the newbie explanation... EDIT</p> <p>I've <a href="http://www.jordillobet.es/taskmanager/fe/" rel="nofollow noreferrer">uploaded the code to a hosting</a> to everyone who want to see the problem "on live".</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload