After two evenings I finally got it to write my own little site from scratch to check the weater.
But one problem i couldn’t resolve.
const getWeather = async () => {
const city = inputField.value;
const urlToFetch = `${weatherUrl}?q=${city}&appid=${openWeatherKey}`;
try {
const response = await fetch(urlToFetch);
if (response.ok) {
const jsonResponse = await response.json();
outputField.innerHTML = `
<div>
<p>
Stadt: ${jsonResponse.name}<br>
Wetter: ${jsonResponse.weather[0].main}<br>
Details: ${jsonResponse.weather[0].description}<br>
Temperatur: ${Math.round((jsonResponse.main.temp-273.15) * 10) / 10}<br>
<img src="https://openweathermap.org/img/wn/${jsonResponse.weather[0].icon}@2x.png">
</p>
</div>`;
}
} catch (error) {
I dont know how to return the jsonResponse like in Wanderlust. I dont get access to the data. I tried to save the invoked function to a variable to get the return of jsonResponse. But it didn’t work. And I really dont have an idea what is going on in Wanderlust with that chained functions and why the values get over these functions. I tried to rebuilt it but I guess I have to practice and reread that.
Here is my first tiny projekt from scratch: https://wetter--kroesus.repl.co/ (not responsive)