dimanche 5 février 2017

Ember data adapter headers are not included in the request

import DS from 'ember-data';
import config from '../config/environment';
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';

export default DS.JSONAPIAdapter.extend(DataAdapterMixin, {
    host: `${config.host}`,
    session: Ember.inject.service(),

    headers: Ember.computed({
        get() {
            let headers = {};
            this.get('session')
                .authorize('authorizer:custom', (headerName, headerValue) => {
                    headers[headerName] = headerValue;
                });
            return headers;
        }
    }),

    queryRecord(modelName, query) {
        return Ember.$.getJSON(`${config.host}/users/me`);
    }
});

I have defined a headers property inside the adapter, however, then the request send to the server there is no Authentication in the header.

I have tried to log the headers property in queryRecord method and it does display the correct header information.




Aucun commentaire:

Enregistrer un commentaire