Basically I have a function called getWeatherForecast which gets some weather data from an api however, I am getting an infinite loop and it keeps requesting for the data an infinite number of times.
Here is my function
const getWeatherForecast = async () => {
const weatherForecast = await axios.get(`${API_ENDPOINT}lat=${props.latitude}&lon=${props.longitude}&exclude=hourly,daily&appid=${API_KEY}`)
console.log(weatherForecast)
setWeatherDetails(weatherForecast)
}
This is how I used the useEffect
useEffect(() => {
getWeatherForecast()
// console.log(`This is the forecast ${weatherDetails}`)
} , [getWeatherForecast])
Any idea why I am getting an infinite loop ?