Last active
September 14, 2020 14:40
-
-
Save nalgeon/f95ecfab833aa0916a9e936aca626049 to your computer and use it in GitHub Desktop.
Пример работы с подсказками DaData на JScript + XMLHTTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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