I am using google's geocoding api to convert an address into a coordinate.
I have the following fetch to accomplish that.
fetch(
`https://maps.googleapis.com/maps/api/geocode/json?address=${prop.address}&key=${
getEnv().APP_PUBLIC_GOOGLE_API_KEY
}`
)
.then((response) => response.json())
.then((data) => console.log(data.results[0].geometry.location));
This successfully console logs the objects that I want to extract from this json.
What I want to know is: How do I use this object within the rest of my code?
For context this code is within a react component
And I want to use the coordinate object I get back inside of the <GoogleMap/>
component's center prop and the <Marker/>
component's position prop.