I am using http://ip-api.com/json API and I am trying to get an object that would hold the city and and the country of a person. This is my code.
$(document).ready(function() {
var locationAPI = "http://ip-api.com/json";
var K, C, F;
var Person = {
    city: function() {
        $.getJSON(locationAPI, function(data) {
            return data.city;
        });
    },
    country: function() {
        $.getJSON(locationAPI, function(data) {
            return data.countryCode;
        });
    }
};
var x = Person.city;
console.log(x); });
This is the output:
function () {
        $.getJSON(locationAPI, function(data) {
            return data.city;
        });
    }
I want it to output a value for ex. - Person.country = USA What am I doing wrong?
 
     
    