jeudi 29 octobre 2015

consuming json in ember and rest-serializer

i'm trying to display in my ember app the data but i can't serialize json which http://ift.tt/1n31l1Y give me. i have it locally but the format is the same. i put in my serializers/application.js this:

export default DS.RESTSerializer.extend({
  normalizePayload: function(type, payload) {

    if (type.toString() === 'App.Posts') {
       return { posts: payload };
    }else{
         console.log(type);
         console.log(payload);
    }
  }
});

in my console, when i read "console.log(type)", it shows to me the array with the Objects (posts) Array [ Object, Object, Object, Object, Object, Object, Object, Object,Object, Obj... and more] and console.log(payload) is undefined thanks if you help me




Aucun commentaire:

Enregistrer un commentaire