Hi everyone, i want to send custom headers, have tried few things but none of them worked.
//in my application adapter, i have added the following
headers: Ember.computed('session.data.authenticated.token', function() {
return {
'header_name': ' header_value '
};
}),
//i have overwritten 'ajax' service to include headers
import Ember from 'ember';
import AjaxService from 'ember-ajax/services/ajax';
export default AjaxService.extend({
session: Ember.inject.service(),
headers: Ember.computed('session.data.authenticated.token', {
get() {
let headers = {};
const authToken = this.get('session.data.authenticated.token');
if (authToken) {
headers['JWT'] = authToken;
}
return headers;
}
})
});
//in my /dashboard route, i made an ajax request to see,
makeGetRequest(){
this.get('ajax').request('http://localhost:3000/api/dashboard',{
method: 'GET'
});
let token = this.get('session.data.authenticated.token');
console.log(token)
}
}
None of these custom headers shown up in req.headers.What should i do to fix this? TIA