Kevin Powell - CommunityKP-C
Kevin Powell - Communityβ€’3y agoβ€’
16 replies
CDL

Weather API App v2

Hi again!

My previous post had too many questions so it got a little chaotic. This one is simpler.

The code below works, it displays the location and temperature, however I don't see any way of applying CSS to it, so i need to change app.textContent to either innerHTML (where I can add a div and then a Class/ID to the div), or maybe createElement etc..

Any advise please? πŸ™‚

    .then(function (response) {
      return response.json();
    })
    .then(function (response) {
      app.textContent = `Location: ${response.location.name} & Temperature: ${response.current.temp_c}`;
    })
    .catch(function (error) {
      console.error("Error fetching weather data:", error);
      app.textContent = "An error occurred while fetching weather data.";
    });
Was this page helpful?