lundi 9 novembre 2015

Ajax promise in Ember with GitHub Api

I was looking to this tutorial in order to work with the GitHub API in my project. In my case i need to use the API for the repos

I can not display the the list of repos from the GitHub API although i can see the model data objects are in my console. See the image

enter image description here

Here my route code

import Ember from 'ember';
import ajax from 'ic-ajax';

var IndexRoute = Ember.Route.extend({
    model: function(params){
        var self;
        self = this;
        return ajax({
            url: 'http://ift.tt/1MRzF2c',
            type: 'get'
        }).then(function(repos){
            repos.forEach(function(item){
                var repo;
                repo = self.createReposList(item)
            });
            return repos;
        });
    },
    createReposList: function(repo){
        return this.store.createRecord('repo', {
            name: repo.name,
            description: repo.description
        });
    }
});

export default IndexRoute;

here my template

<div class="github__repos">
  {{#each repo}}
   <p>{{repo.name}}</p>
   <p>{{repo.description}}</p>
  {{/each}}
</div>

What i am doing wrong to not display the model data i retrieve from the Github Api?




Aucun commentaire:

Enregistrer un commentaire