Skip to content

Instantly share code, notes, and snippets.

@nalgeon
Last active September 14, 2020 14:40
Show Gist options
  • Save nalgeon/f95ecfab833aa0916a9e936aca626049 to your computer and use it in GitHub Desktop.
Save nalgeon/f95ecfab833aa0916a9e936aca626049 to your computer and use it in GitHub Desktop.
Пример работы с подсказками DaData на JScript + XMLHTTP
var API_KEY = "ВАШ_API_КЛЮЧ";
function suggest(resource, query) {
var http = new ActiveXObject("MSXML2.XMLHTTP");
http.open("POST", "http://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/" + resource, false);
http.setRequestHeader("Content-Type", "application/json");
http.setRequestHeader("Authorization", "Token " + API_KEY);
var data = "{ \"query\": \"" + query + "\" }";
http.send(data);
return http.responseText;
}
resp = suggest("party", "7719402047");
WScript.Echo(resp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment