I'm learning Ember and after some basic test, I tried to connect with my API to created a search component.
API 'application/vnd.api+json'
{
"data": [
{
"expediente": "1717801",
"fecha_de_presentacion": "01/02/2016 12:00:00 AM",
"figura_juridica": "REGISTRO DE MARCA",
"logotipo": null,
"signo": "IGUY",
"tipo": "NOMINATIVA",
"titular": "SAMSONITE IP HOLDINGS S.\u00c0.R.L."
},
{
"expediente": "1717793",
"fecha_de_presentacion": "01/02/2016 12:00:00 AM",
"figura_juridica": "REGISTRO DE MARCA",
"logotipo": "1_files/direct_151.gif",
"signo": "URGOSTART",
"tipo": "MIXTA",
"titular": "HCP HEALTHCARE ASIA PTE. LTD"
},
{
"expediente": "1717780",
"fecha_de_presentacion": "02/02/2016 12:00:00 AM",
"figura_juridica": "REGISTRO DE MARCA",
"logotipo": null,
"signo": "SKALAR",
"tipo": "NOMINATIVA",
"titular": "SKALAR HOLDING B.V."
},
{
"expediente": "1717811",
"fecha_de_presentacion": "02/02/2016 12:00:00 AM",
"figura_juridica": "REGISTRO DE MARCA",
"logotipo": "1_files/direct_189.gif",
"signo": "MELI MELO",
"tipo": "MIXTA",
"titular": "MELI\u00b4MELO\u00b4 LIMITED"
}
]
}
app/templates/index.hbs
{{input value=search}}
<ul>
{{#each model as |trademark|}}
<li>{{trademark.signo}}</li>
{{/each}}
</ul>
app/controller/index.js
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: ['search'],
search: ""
});
app/models/trademarks.js
import DS from 'ember-data';
export default DS.Model.extend({
figura_juridica: DS.attr('string'),
expediente: DS.attr('string'),
titular: DS.attr('string'),
signo: DS.attr('string'),
tipo: DS.attr('string'),
fecha_de_presentacion: DS.attr('date'),
logotipo: DS.attr('string')
});
app/route.js
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.route('trademarks');
});
export default Router;
app/adapters/application.js
import DS from 'ember-data';
export default DS.JSONAPIAdapter.extend({
host: 'http://localhost:5000',
namespace: 'v1'
});
if I extends from JSONAPIAdapter i got this error:
Error while processing route: index Assertion Failed: Encountered a resource object with an undefined type (resolved resource using ui@serializer:-json-api:)
I changed to extended my adapter from JSONAPISerializer but only got another error.
import DS from 'ember-data';
export default DS.JSONAPISerializer.extend({
host: 'http://localhost:5000',
namespace: 'v1'
});
Error while processing route: index Assertion Failed: You tried to load a query but your adapter does not implement
query
EmberError@http://localhost:4200/assets/vendor.js:26674:1