# Get the address metadata
response = await address_search(address=address, results_limit=1)
response_body_str = response.body.decode()
print(response_body_str)
address_search_results = json.loads(response_body_str)
print(address_search_results)
print(type(address_search_results))
#Extract the Latitude and Longitude from the address search results
latitude = float(address_search_results['features'][0]['properties']['LATITUDE'])
longitude = float(address_search_results['features'][0]['properties']['LONGITUDE'])
This is returning the following error:
File "/code/routers/address_and_meta_search.py", line 29, in single_address_and_meta_search
latitude = address_search_results['features'][0]['properties']['LATITUDE']
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
TypeError: string indices must be integers, not 'str'
But when I replicate it in a terminal, it works fine?
response_body_str = "{\"type\": \"FeatureCollection\", \"features\": [{\"id\": \"0\", \"type\": \"Feature\", \"properties\": {\"LATITUDE\": \"-37.00000\", \"LONGITUDE\": \"145.00000\", \"@search.score\": 8.628523, \"@search.reranker_score\": null, \"@search.highlights\": null, \"@search.captions\": null}, \"geometry\": {\"type\": \"Point\", \"coordinates\": [145.0000, -37.00000]}}]}"