var dadataToken = ""; // Put your token
var search = ""; // Put your search string
var xhr = new XMLHttpRequest();
xhr.open(
'POST',
'https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/address',
true
);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Token " + dadataToken);
xhr.send(JSON.stringify({"query": search}));
xhr.onload = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
var jsonResponse = JSON.parse(xhr.responseText);
if (jsonResponse.suggestions) {
window.console.log("jsonResponse.suggestions = " + JSON.stringify(jsonResponse.suggestions));
}
}
}