lundi 19 décembre 2016

Accessing metadata attr on template

I have a mocked api endpoint with ember-cli-mirage and with some metadata. I did override the model serializer to add that metadata like this:

import { JSONAPISerializer } from 'ember-cli-mirage';

export default JSONAPISerializer.extend({
    serialize(object, request) {
        let json = JSONAPISerializer.prototype.serialize.apply(this, arguments);

        json.meta = {
            compass_size: 1,
            arrow_size: 2,
            total: 3
        }

        return json;
    }
});

The api call returns that metadata correctly:

Object
    data: Array[10]
    meta: Object
     arrow_size: 2
     compass_size: 1
     total: 3
     ...

Given I have this route handler:

import Ember from 'ember';

export default Ember.Route.extend({
  model() {
    return this.get('store').findAll('events');
  }
});

When I try to print that data on my template



then nothing is rendered. Am I missing something?




Aucun commentaire:

Enregistrer un commentaire