I want to get city from the given api and display it. The output on console is undefined.This is what I have so far:
$.getJSON("http://ip-api.com/json", function(data1){
city = data1.city;
$("#city").html(city);
});
console.log(city);
How can I do this successfully?