After gathering insights from the responses to this and this queries, I have formulated the code below for a GET request:
var setHeader = function (xhr) {
xhr.setRequestHeader("Authorization", "Basic " + btoa($rootScope.login.Gebruikersnaam + ":" + $rootScope.login.Wachtwoord));
}
$rootScope.getCollection = function () {
return new(Backbone.Collection.extend({
url : $rootScope.login.Serverlocatie + '/Table?Active=true&SL=ID'
}));
}
$rootScope.getCollection().fetch({
beforeSend : setHeader
}).then(function (a) {
console.log(a);
});
Despite expecting a successful GET operation with the specified request header, the obtained response is as follows:
Request Method:OPTIONS
Status Code:400 Not a REST method:
So, it appears that the OPTIONS method is not permissible. Strangely, a simple GET operation (via ajax) works perfectly fine.
Hence, the query arises: How can I execute a GET call instead of OPTIONS in this specific situation?