nihique
nihique

Reputation: 5788

Setup Breeze JS ajax adapter to send query string params instead headers

Is it possible to setup Breeze JS ajax adapter to send additional query strings parameters? Now I am using custom headers params, but want to change our app to use query string params instead.

Current code:

    function configureAjaxAdapter() {
        var ajaxAdapter = breeze.config.getAdapterInstance("ajax");
        ajaxAdapter.defaultSettings = {
            beforeSend: function(xhr, settings) {
                xhr.setRequestHeader("db", config.db);
                xhr.setRequestHeader("login", config.login);
            }
        }; 
    }

Upvotes: 0

Views: 822

Answers (1)

Jay Traband
Jay Traband

Reputation: 17052

Take a look at the EntityQuery.withParameters method. This is the "preferred" (and safe) mechanism to pass query string params in a query. For example:

var params = {
   db: config.db,
   login: config.login
};

var q = EntityQuery.from("Foos").withParameters(params);
myEntityManager.executeQuery(q).then(...) 

Upvotes: 1

Related Questions