Set a default Base URL for Ajax Calls

Hello!

I’m evaluating Webix, and find it a, awesome library, but I would like to set a default base URL for my ajax calls, something like we can do on Axios.

Example on Axios:
axios.defaults.baseURL = ‘http://httpbin.org’;

and after it, axios.get(’/get’) will result in ‘GET - http://httpbin.org/get

I have tried to use the global onBeforeAjax Event, and for setting a header it works, but I couldn’t find a way to concat something in the url at that context.

If it’s just for saving forms or for very particular use cases, I’d just create a Adapter, but I need it to load all combos and data collection in the app, it’ll be a pain to manually loading each one, or, having to concat manually in each request.

Thanks!

as a workaround you can try to override global XMLHttpRequest.open method

(function (prototype) {
    var _open = prototype.open;
    prototype.open = function () {
        arguments[1] = "SOME_PREFIX" + arguments[1]; //change passed url
        return _open.apply(this, arguments);
    }
}(XMLHttpRequest.prototype));

this will affect ALL ajax calls

Wow, it’s a nice workaround, I tried and really worked. Thanks bro!