d3 update

This commit is contained in:
Garry Ing
2021-05-09 11:49:58 -04:00
parent a9bcd1a66c
commit ac0910f343
7 changed files with 19 additions and 14 deletions

View File

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