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

170
Visualizações
Failed to load resource after using API Key

I have this error "Failed to load resource: the server http://localhost:3000/api.openweathermap.org/data/2.5/weather?id=&appid=23012caa6cd9437d2588b8f412b67f5f responded with a status of 404 (Not Found)

let baseURL = 'api.openweathermap.org/data/2.5/weather?id=&appid=';
let apiKey = '23012caa6cd9437d2588b8f412b67f5f';
let newZip =  document.getElementById('zip').value;



document.getElementById('generate').addEventListener('click', performAction);
var feeling=document.createElement('DIV');
document.getElementById("feeling").appendChild(feeling);
function performAction(){
getWeather(baseURL,newZip, apiKey);
feeling.innerHTML=document.getElementById('feelingLabel').value;

}
async function getWeather (baseURL,newZip ,apikey){

  const res = await fetch(baseURL+newZip+apikey)
  try {

    const projectData = await res.json();
    
    console.log(typeof projectData);
   let date= document.createElement('DIV');
  document.getElementById("container").appendChild(date);
   let temp=document.createElement('Div');
   document.getElementById('container').appendChild(temp);
   let content=document.createElement('DIV');
   document.getElementById("container").appendChild(content);
   date.innerHTML=projectData[1];
   temp.innerHTML=projectData[2];
   content.innerHTML=projectData[3];
    return projectData;
  }  catch(error) {
    console.log("error", error);
    // appropriately handle the error
  }
}

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You didn't specify any protocol in your baseURL, so the browser think you want to send a request to your own server (in your case localhost:3000) instead of to OpenWeatherMap. Try prepending either https:// or http:// to baseURL, like this:

let baseURL = 'https://api.openweathermap.org/data/2.5/weather?id=&appid=';
about 4 years ago · Juan Pablo Isaza Relatório
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