Im geocoding my address, from something like "Address 150, City" to it's latitude and longitude using Google Geocoding API. At the end of a function, im trying to return an object, which contains these two as shown in code below.
I've thought that the problem may be, that the coding takes quite some time, and since I wanted to resolve this problem today and I haven't learned await and async with promises and stuff(i will do that tommorow, dont worry), I used setTimeout instead, but it didnt solve the problem even thought I was calling console.log after the coding was done. Since I'm new to JS, I then just tried to wrap it into variable, just play with the code a little, but neither did help.
            // address
            var address = "Address 156, City"
            function geocode(address) {
                axios.get("https://maps.googleapis.com/maps/api/geocode/json", {
                    params: {
                        address: address,
                        key: "AIzaSyDaXOpbCeLYeRxWXtuSQQEbQzR14PejczM"
                    }
                })
                    .then((response) => {
                        let lngLat = {
                            lat: response.data.results[0].geometry.location.lat,
                            lng: response.data.results[0].geometry.location.lng}
                        console.log(lngLat) // here it shows me my object
                        return lngLat;
                    })
            }
            let geocodedAddress = geocode(address);
            setTimeout(function () { console.log(geocodedAddress); }, 3000);               
        }
    });
 
     
    