Skip to content

Instantly share code, notes, and snippets.

@martinkunc
Created October 16, 2021 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinkunc/632b1fd1ad39afc575b3e4a51acf8ca5 to your computer and use it in GitHub Desktop.
Save martinkunc/632b1fd1ad39afc575b3e4a51acf8ca5 to your computer and use it in GitHub Desktop.
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}&deg;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