I'm new to react development. I tried to create a simple project which searches for the weather of a city by using an API. Using fetch I tried to call the API:
getWeather = async (e) => {
e.preventDefault();
const url = 'https://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=${API_KEY}';
const api_call = await fetch(url);
const data = await api_call.json() ;
console.log(data);
}
But when I submit, the console log says wrong API KEY. Instead if I give the API key directly into the URL it works, can somebody help me?
API_KEYbeing set?https://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=${API_KEY};https://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=${API_KEY}