Created
October 16, 2021 11:17
-
-
Save martinkunc/632b1fd1ad39afc575b3e4a51acf8ca5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import './index.css' | |
import 'jquery' | |
import { IWeatherForecast, WeatherClient } from '../Services/weather/weather'; | |
export class IndexRenderer { | |
weatherClient: WeatherClient; | |
constructor() { | |
this.weatherClient = new WeatherClient(); | |
} | |
formatDate = (date: Date): string => { | |
return `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`; | |
} | |
onReady = async () => { | |
let hello = 'The current weather from Api'; | |
$("div.text-center").append(`<h1 id='msg'>${hello}</h1>`); | |
let weatherMeasures = await this.weatherClient.get(); | |
for (var i = 0; i < weatherMeasures.length; i++) { | |
$("div.text-center").append(`<span>${this.formatDate(weatherMeasures[i].date)} - ${weatherMeasures[i].temperatureC}°C - ${weatherMeasures[i].summary}</span><br/>`); | |
} | |
} | |
} | |
let index = new IndexRenderer(); | |
$().ready(index.onReady); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment