Quantcast
Viewing all articles
Browse latest Browse all 4827

Ember incorrectly deserializing data from API

@luizkowalski wrote:

Hello everyone!
So, I've struggling with something that many people also been through, but I couldn't find any solution.

I have an API returning data as follows:

[
  {
    "createdAt": 1391708660000,
    "uid": 16587783,
    "name": "FRaaS",
    "fullName": "caarlos0/FRaaS",
    "description": "Fake RT as a Service",
    "homepage": "http://fraas.herokuapp.com/",
    "owner": "caarlos0",
    "organization": null,
    "joined": false,
    "private": false
  },
.... keeps going on

basically, it is a list of Github repos.
I want to show them in my app, so I created a new model and the routes, etc

import DS from 'ember-data';

export default DS.Model.extend({
  uid: DS.attr('integer'),
  name: DS.attr('string'),
  fullName: DS.attr('string'),
  description: DS.attr('string'),
  homepage: DS.attr('string'),
  owner: DS.attr('string'),
  private: DS.attr('boolean')
});

and loading them in the route

export default Ember.Route.extend(AuthenticatedRouteMixin,{
  session: Ember.inject.service('session'),
  model(){
    return this.get('store').findAll('room');
  },

but for some reason, I keep seeing this message

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

and I see like 100 times this in the console, just changing the "0" to "1" and so on...
AFAIK, Embers expects a json with a root, and the api returns without a root. what can I do?

I'm using ember 2.7.0

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4827

Trending Articles