Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

260
Visualizações
Uncaught ReferenceError: getweather is not defined at HTMLButtonElement.onclick (index.html:31)
<!DOCTYPE html>
<html>
  <head>
<link href="style.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
   <h1>Random Stuff</h1>
    <script>
    import fetch from "node-fetch";
      function getweather(){
            fetch('http://api.weatherapi.com/v1/current.json?key=f085cc2632a24b64965195959210710&q=84065&aqi=no')
                  .then(response => response.json())
                  .then(data => {
                        const weather = data.current.temp_f;
                        setweather(weather);
                        })
                  }
      function setweather(weather) {
            console.log(weather)
            document.getElementById("temp").innerHTML = weather;
      }
      
      
      
      
      </script>
    <input type="number" placeholder="Type something..." id="myInput", pattern="[0-9]*">
    <button type="button" onclick="getweather()">Get Value</button>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  </body>
<button onclick="getweather()", id="id">Click me</button>
<h1>The weather is:</h1>
<h2 id="temp"></h2>
</html>

Here I have my HTML file and whenever I click a button I get the error (in the title) I have been trying to find out why this isn't working, I have just started HTML, CSS, and JS the answer may be obvious but I cant seem to fix it.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda