Weather api 404 not found problem

here is my code


const weatherBtn = document.getElementById('get-weather-btn');

const dropDownMenu = document.getElementById('drop-down'); 

const mainTemperature = document.getElementById('main-temperature');
const weatherMain = document.getElementById('weather-main');
const location = document.getElementById('location');


dropDownMenu.addEventListener('input', (e) => {
  if(!e.target.value) {
    weatherBtn.disabled = true
    weatherBtn.style.cursor = 'not-allowed'

  }
    weatherBtn.style.cursor = 'pointer'
    weatherBtn.disabled = false

  
  
})

const showWeather = () => {
  getWeather()
}
async function getWeather (city) {
  try {

 const res = await fetch(`https://weather-proxy.freecodecamp.rocks/api/city/${city}` )
  const data = await res.json()
  console.log(data)
  return data
  
}catch(error) {
    console.error(`Error: ${error}`)
  }
}
weatherBtn.addEventListener('click', () => {
  if(!showWeather()) {
    mainTemperature.textContent = 'N/A'
  }
  console.log(!showWeather())
  location.textContent = dropDownMenu.value
})  

and here is what i meet

and here is console message about the error
/learn/javascript-v9/lab-weather-app/[object%20HTMLElement]:1 Failed to load resource: the server responded with a status of 404 ()

Please use another name for your #location reference. That should solve this issue.

1 Like

yes it work, thanks so much for your help