jeudi 18 février 2016

Emberjs - how to retrieve custom headers and render in view

So I had a look at this

and so I created /adapters/application.js

MyApp.ApplicationAdapter = DS.RESTAdapter.extend({
 handleResponse: function(status, headers, payload) {
   meta = {
     msg: headers["X-Message"],
     type: headers["X-Message-Type"]
   };
   payload.meta = meta;
   return this._super(status, headers, payload);
  }
});

I added this to the correct controller:

  message: function() {
    return (this.get('MyApp.meta.msg'));
  }.property('MyApp.meta.msg')

I tried to access this in the handlebars template with

{{message}}

but I get nothing rendered (and no errors in the console either). I can confirm that the headers do exist in the response (and they have data).

What am I missing here?




Aucun commentaire:

Enregistrer un commentaire