I know there are many questions about this issue but my problem is different I managed to get the data outside of $.getJSON() but I couldn't access them
var country = {} ;
$.getJSON('https://freegeoip.net/json/', function (code) {
country.config = code ;
});
console.log(country);
I will get these information
{}config: {ip: "**********", country_code: "LB", country_name: "Lebanon", region_code: "06", region_name: "Beirut", …}proto: Object
if I try to access them like this
country.config.country_code
I will get this error
fdgdfgd:643 Uncaught TypeError: Cannot read property 'country_code' of undefined
I can't even access this one
country.config
How can I get the data from this object ?