I'm using the google geocoding API and I'm trying to get the city. This is I'm getting the info.
const city = data.results[0].address_components[3].long_name
The issue with this is that the response will be different depending on the address the user gives. In some, it will be in address_components[2] instead of 3. The city is in the response but in a different array.
Is there a way to always get the city regardless of where in the array it is?