[SOLVED] Can someone look at my Local Weather App code?


I set up my location, but it won’t show in my html. Also, I might not nave my ajax working correctly. Would appreciate another set of eyes. Thanks in advance.

Pen: https://codepen.io/BlackMG27/pen/rzWqgY
API that I used: http://ip-api.com/docs/api:json


You are hitting a couple of issues.

  1. Your getLocation() function is never called
  2. When you call getLocation(), you get a Mixed-content error because you are trying to call an API over HTTP instead of HTTPS.

For the first issue, add getLocation() to your getAll() function.

For the second issue, you’ll need to choose a different API that supports HTTPS, you can use this URL instead: https://ipinfo.io/json.


Thanks for the link! I tried adding getLocation() to getAll() using .bind() and .apply(), but I kept getting Uncaught TypeError: Cannot read property 'apply' of undefined referring to getLocation() .


getAll() executes the function then .apply is used on what that function returns, since getAll isn’t returning anything it is undefined.
getLocation is in the scope of getAll and can be called inside of it, however getLocation is not accessible outside of getAll.

function foo(){
    function bar(){
foo() // bar
bar() // Reference Error bar is not defined

When using call, bind, apply use fn.bind() , fn.call(), fn.apply(), where fn is the function name.



I fixed the issue…for the most part. Do we have to show the location’s country? If not, then I fixed it! Thank you so much!


I have two more issues: I need some help with my weather icons and my switch button. The icons won’t show and the button doesn’t work. Thanks in advance.


line 135: forgot the . in $(“tempGet”);
Icons are working for me.


I got the icons to work. I forgot to get the cdn. :yum: