Return Yahoo! weather API data in Celsius, using YQL

前端 未结 3 767
长情又很酷
长情又很酷 2021-02-12 18:45

I\'m trying to get Yahoo! weather API with temperatures in Celsius.

I\'ve added &u=c in the request, but it\'s still returning data in Fahrenheit.

3条回答
  •  梦毁少年i
    2021-02-12 19:05

    Whenever I had to call a temperature that I wanted in Celsius I just used a simple conversion function:

    function FtoC(temp) {return Math.round((temp - 32) / (9 / 5));}
    

    Then again, I wanted to toggle between Fahrenheit and Celsius. Just calling the Celsius JSON element from Yahoo is probably better if all you want to use is Celsius.

提交回复
热议问题