I'm building a Weather App for FreeCodeCamp. Here's the link to my CodePen.
I'm pulling in my current location details from this API. I'm trying to assign the object properties from the results obtained to other variables but my webpage keeps breaking down. For example -
var city;
var location;
$.getJSON("http://ip-api.com/json", function(a) {
city = a.city;
location = city;
});
The above code breaks my page with the following error in the console -
pen.js:14 GET http://s.codepen.io/boomerang/ec76a96f53a8031f8d1405309568a2711480895619856/Greenville 404 (Not Found)
The page works fine when I assign a.city to city, but only breaks down when I assign city to location. If I console.log(city), it logs my city, i.e, the value from a.city, to the console. So all I'm doing is assigning the value of city to another variable location. What could be the reason this isn't working?
404, i.e., the URL does not work. That is why it is broken.console.log(a.lat), I'm able to log the latitude of my location.citytolocation. Otherwise the page doesn't break. For example, if I comment outlocation = city, the page renders properly.