mardi 10 mai 2016

Ember, JSONAPIAdapter, JSONAPISerializer, findAll not available

Im building an Ember app "ember-cli": "2.4.3", sitting on Laravel/Lumen and cant seem to get the wires hooked up correctly. Im trying to also an API server JSON-API compliant, so I have access to alter the syntax if thats a problem.

If I remove the export default DS.JSONAPISERIALIZER, I get ember.debug.js:32116 TypeError: typeClass.eachTransformedAttribute is not a function

With it, I typically get Assertion Failed: You tried to load all records but your adapter does not implement findAll

If I call getJSON(...) from within the route, instead to calling the store for the data, it works perfectly, and displays to the view as expected.

I have tried other adapters but I think that being JSON-API compliant I need to use the JSONAPIADAPTER. Any help would be awesome.

application.js

import DS from "ember-data";

export default DS.JSONAPIAdapter.extend({
 namespace: 'v1',
 host: 'http://edu-api.app:8000',
});

export default DS.JSONAPISerializer.extend({
 //in preparation of underscores in returned data
 //   keyForAttribute: function(attr) {
 //     return Ember.String.underscore(attr);
 //   },
 //   keyForRelationship: function(attr) {
 //     return Ember.String.underscore(attr);
 //   }
});

skill.js

import DS from 'ember-data';
var App = window.App = Ember.Application.extend();
var attr = DS.attr;

App.Skill = DS.Model.extend({
  name: attr("string"),
  desc: attr("string")
});

index.js

export default Ember.Route.extend({
  model() {
    //return this.store.findAll('skill');  //<- Assertion Failed: You tried to load all records but your adapter does not implement `findAll`
    this.get('store').findAll('skill');  //<- Assertion Failed: You tried to load all records but your adapter does not implement `findAll`
    //return Ember.$.getJSON('http://ift.tt/1ZBD2w6'); //<- works, and properly displays data to view
  }
});




Aucun commentaire:

Enregistrer un commentaire