Need a TypeScript example for synchronous call with webix.ajax like in JavaScript

Hello,
I need an TypeScript example for synchronous call with webix.ajax like in JavaScript:

var response = webix.ajax().headers({ “Content-type”: “application/json” }).sync().get(“myURL”);
var responseText = response.responseText;

Can anyone help me?

Hey @vsinner, the syntax for this is the same as it is in JavaScript, if you are getting an error while trying to call this method using TypeScript (and the error is connected with type definitions), as a workaround in webix.global.d.ts replace this:

function ajax(url?: string, params?: any):webix.Ajax | Promise<any>;

with this:

function ajax(url: string, params?: any):Promise<any>;
function ajax():webix.Ajax;

Hey Dzmitry, thank you for the answer and problem resolving!
Yes, I have getting the error by trying to call this method using TypeScript.
Will be this error corrected in the next version of Webix?

This issue has been reported before, I hope to get this updated as soon as possible, but I can’t really provide a time frame for the fix at the time being unfortunately.

this problem can be solved without editing webix.global.d.ts
to override global definitions, you need to create own definitions

webix.override.d.ts

declare namespace webix {
    function ajax(): webix.Ajax;
    function ajax(url: string, params?: any): Promise<any>;
}

this is required for forward compatibility.
to not edit global definitions after each update.

the main problem is that new file must be loaded after global one.
if they are in the same folder, then no problem, as alphabetically new file is coming after global one.
in other case, you should check locations, to make sure that overrides loaded after global definitions.

Good idea! Thank you!