This commit is contained in:
Garry Ing 2021-05-09 11:54:11 -04:00
parent ac0910f343
commit dff470164c
No known key found for this signature in database
GPG Key ID: 3B379B1F2193CC3E

View File

@ -144,6 +144,8 @@ if (typeof window.graphDataIndex !== 'undefined') {
// Notes graph // Notes graph
const d3 = window.d3
if (typeof window.graphData !== 'undefined') { if (typeof window.graphData !== 'undefined') {
const MINIMAL_NODE_SIZE = 10 const MINIMAL_NODE_SIZE = 10
const MAX_NODE_SIZE = 16 const MAX_NODE_SIZE = 16
@ -402,15 +404,15 @@ const capitalize = str => `${str.charAt(0).toUpperCase()}${str.slice(1)}`
const conditionsContainer = document.getElementById('gardenConditions') const conditionsContainer = document.getElementById('gardenConditions')
const openWeatherUrl = 'https://garden-weather-api.vercel.app/weather/toronto' const openWeatherUrl = 'https://garden-weather-api.vercel.app/weather/toronto'
async function fetchWeather() { async function fetchWeather () {
let response = await window.fetch(openWeatherUrl) const response = await window.fetch(openWeatherUrl)
let weatherData = await response.json() const weatherData = await response.json()
conditionsContainer.innerHTML = `${capitalize(weatherData.weather[0].description)}, ${Math.round(weatherData.main.temp)}°C` conditionsContainer.innerHTML = `${capitalize(weatherData.weather[0].description)}, ${Math.round(weatherData.main.temp)}°C`
conditionsContainer.classList.remove('dn') conditionsContainer.classList.remove('dn')
} }
if (conditionsContainer) { if (conditionsContainer) {
fetchWeather().catch(e => { fetchWeather().catch(e => {
console.log('There has been a problem with getting the weather ' + e.message); console.log('There has been a problem with getting the weather ' + e.message)
}); })
} }