I'm failing trying to add headers to my already working sync method. I figured i'd either pass them as a key: object, or set them in options; both methods I saw in different posts. Neither attempts surface the headers in chromes network tab, or my api logs.
I've also attempted setting this globally through jquery settings:
$.ajaxSetup({
headers: { 'x-my-custom-header': 'some value' }
});
Any help would be much appreciated!!!
As options hash.
sync: function(method, model, options) {
options.headers = { 'X-Key-Whatever' :'Foobar' }
// Default JSON-request options.
var params = _.extend({
type: 'GET',
dataType: 'jsonp',
url: model.url(),
processData: false,
jsonpCallback: 'abcShowSomething',
cache: true
}, options);
// Make the request.
return $.ajax(params);
},
As params key:
sync: function(method, model, options) {
// Default JSON-request options.
var params = _.extend({
type: 'GET',
headers: { 'X-Key-Whatever' :'Foobar' },
dataType: 'jsonp',
url: model.url(),
processData: false,
jsonpCallback: 'abcShowSomething',
cache: true
}, options);
// Make the request.
return $.ajax(params);
},