javascript fetch api template string
javascript fetch api template string I'm trying to make an app that gives you the weather based on your location. I get the location with ipinfo, and it works. I put the location in a variable, and when I console log it it still works. But when I try to fetch data from openweathermap with that variable using a template string this is what the console shows: Uncaught (in promise) ReferenceError: currentCity is not defined at getWeather The problem is when I copy that link to the console it returns a link that works! Thanks for the help const getLocation = async () => { const response = await fetch('http://ipinfo.io/json?token=(id given by ipinfo)') if (response.status === 200) { const data = await response.json() return data.city } else { throw new Error('Unable to get the current location') } } let currentCity getLocation().then((city) => { currentCity = city ...