vendredi 9 décembre 2016

unable to parse API response in ember

I am trying to learn EmberJS and restify. I have get method API with following response :

 {"products":[{"id":1,"name":"lappy1"},{"id":2,"name":"lappy2"}]}

This response I am getting in my browser's network log.

My product route is like :

 import Ember from 'ember';
      export default Ember.Route.extend({
          model() {
              return {
                  products :this.get('store').findAll('product')
              };
          }
      });

My product.hbs is :

<div>
<div class="row">
    <div class="col-md-4"><b>id</b></div>
    <div class="col-md-4"><b>Name</b></div>     
</div>

    <div class="row">
        <div class="col-md-4"></div>
        <div class="col-md-4"></div>
    </div>

</div>

My product model is :

import DS from 'ember-data';

export default DS.Model.extend({
    name:  DS.attr('string')
});

There is no any error on log, but my page only shows header part i.e

<div class="col-md-4"><b>id</b></div>
<div class="col-md-4"><b>Name</b></div> 

which thing I am missing ?




Aucun commentaire:

Enregistrer un commentaire