xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

Metric temperature and Imperial temperature All In One

Metric temperature and Imperial temperature All In One

Metric and Imperial / 公制和英制

Metric temperature

公制温度

Imperial temperature

英制温度

Celsius / Fahrenheit

摄氏度 / 华氏度

demo

Weather API


/**
 * Get's the latest forecast data from the network.
 *
 * @param {string} coords Location object to.
 * @return {Object} The weather forecast, if the request fails, return null.
 */
function getForecastFromNetwork(coords) {
  console.log('coords =', coords);
  // console.log('coords =', coords);
  // const location = req.params.location || '40.7720232,-73.9732319';
  const location = '40.7720232,-73.9732319';
  const API_KEY = `31977d6102fca95a51a571a081d05538`;
  const BASE_URL = `https://api.openweathermap.org/data/2.5/onecall`;
  // const url = `${BASE_URL}/${API_KEY}/${location}`;
  const url = `${BASE_URL}?lat=${latitude}&lon=${longitude}&appid=${API_KEY}&units=imperial`;
  // const url = `https://pwa.xgqfrms.xyz/pwa-app/weather-api.json`;
  // const url = `https://api.darksky.net/forecast/1dda89e666ce89b777d2412eac3026d8/${coords}`;
  // const url = `/forecast/${coords}`;
  return fetch(url)
    .then((response) => {
      return response.json();
    })
    .then(json => {
      console.log(`network json`, json);
    })
    .catch((err) => {
      console.error('Error getting data from cache', err);
      return null;
    });
}

units=imperial

https://api.openweathermap.org/data/2.5/onecall?lat=31.2243085&lon=120.9162955&appid=202277d6102fca95a51a571a081d0666&units=imperial

refs

https://en.wikivoyage.org/wiki/Metric_and_Imperial_equivalents



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @   xgqfrms  阅读(164)  评论(1编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2021-04-26 1st & 2nd & 3rd & 4th & 5th All In One
2021-04-26 free UML tools All In One
2021-04-26 vue custom directive All In One
2020-04-26 2020 上海驾照考试流程 All In One
2020-04-26 select notes mark
2020-04-26 Redis All In One
2019-04-26 npm link & unlink All In One
点击右上角即可分享
微信分享提示