JSFiddle - React, Tailwind, and code Playground
JavaScript
function getCountry(access_token, country){
var countryId;
var query={
need_all: 1,
access_token: access_token,
count: 1,
code: country
}
$.ajax({
url: "https://api.vk.com/method/database.getCountries",
dataType: "jsonp",
data: query,
success: function( data ) {
countryId = data.response[0].cid;
console.log(countryId); //печатает всё верно, например 1 для 'RU', 19 для 'AU'
return countryId;
},
error:function(){
console.log("Something went wrong");
}
});
}