samedi 6 août 2016

Ember incorrectly deserialize json data

So I have a Spring Boot api returning a bunch of records in a list, like that:

[
  {
    "uid": 16587783,
    "createdAt": 1391708660000,
    "name": "FRaaS",
    "fullName": "caarlos0/FRaaS",
    "description": "Fake RT as a Service",
    "homepage": "http://ift.tt/2aH9tsT",
    "owner": "caarlos0",
    "organization": null,
    "joined": false,
    "private": false
  },
  ....
  more records
]

but when I try to read it in the template, I get the following error

WARNING: Encountered "0" in payload, but no model was found for model name "0" (resolved model name using chathub-ember@serializer:-rest:.modelNameFromPayloadKey("0"))

Here is my current adapter

import DS from 'ember-data';
import Ember from 'ember';

export default DS.RESTAdapter.extend({
  host: 'http://ift.tt/2auZHqt',
  primaryKey: 'uid',
  headers: Ember.computed('session.data.authenticated.currentUser.backendAccessToken', function() {
    return {
      "Auth-Token": this.get("session.data.authenticated.currentUser.backendAccessToken"),
    };
  })
});

what can I do in ember to allow it to read the data as I sent? I can change the API if needed, but I would rather not to




Aucun commentaire:

Enregistrer un commentaire