Passing the QueryString in the headers of a REST call

I would like to pass the queryString of the current rest call as a parameter in my headers.

Here is an example of code:

App.AppSessionAdapter.reopen({
    namespace: 'api',
    host: function () {
        return 'https://something/';
    }.property(),
    headers:
    {
        'AUTH': 'I need The QueryString to this REST Call. eg: UserID="12134"&Date="10/15/16"'
    }
});

Thanks for your help!

Since you require looking at the data you are sending on your request, you might want to look into extending the RESTAdapter and overriding the ajax method.

https://github.com/emberjs/data/blob/v1.13.4/packages/ember-data/lib/adapters/rest-adapter.js#L860 In there, use options.data to extend the Adapter’s headers, eg.

untested code

ajax: function(url, type, options) {
  var data = options.data || {};
  var headers = this.get('headers') || {};
  Ember.merge(headers, data);
  return this._super.apply(this, arguments);
}

Thanks @neojp. That did it!

Great! I didn’t even test it :slight_smile: