Weather widget running in Firefox but not in Chrome or codepen

Weather widget running in Firefox but not in Chrome or codepen
0

#1

Hello

I finished the weather widget project, the issue, it is working only in Firefox but not on Chrome or codepen.


#2

Change your http to https on your API call.


#3

thank you. it did the trick

but now the switch between F and C isn’t working even though it is locally ?


#4

Same problem, different function. Check your code and you will see another http which should be https. Also, there is no need to call the API twice as you are doing. Once you have the temperature data from the page load, you can save the Celsius and Fahrenheit values to variables to use to display the correct temps when clicking on the F and C buttons.


#5

You are right again, I thought i changed it before, but i realized i changed the url of the weather icon .

The API only sends the temp either in metric C or in Kelvin or in imperial F, I can store the Temperature values and use a function to convert from C to F, that is a way of doing it if i don’t call the API again to grab the other unit.

What do you think about it ?


#6

I believe that is a much better way of handling the data.


#7

There is math equation to convert C to F and C to F


The FCC challange --> https://www.freecodecamp.org/challenges/convert-celsius-to-fahrenheit

The in-depth explanation --> https://www.mathsisfun.com/temperature-conversion.html



#8

I forgot about it. Thank you :slight_smile:

function convertToF(celsius) {
  var fahrenheit;
  // Only change code below this line
  
  fahrenheit = celsius * 9/5 + 32;
  // Only change code above this line
  return fahrenheit;
}