Get Place
getPlace
is used to get the full details for a place using a place_id
from autocompletePlaces
.
Usage
getPlace
takes in the following object:
interface GetPlaceRequest {
placeId: string;
}
placeId
is theplace_id
from anAutocompletePlace
object returned from theautocompletePlaces
function.
Example
const getPlaceRequest = {
placeId: 'G:ChIJFcXEG65ZwokRLH0n5pmtMIQ'
};
try {
const response = await sdk.places.getPlace(getPlaceRequest);
} catch (error) {
// Handle errors
}
Return Value
On success the following object is returned. Note that if no match is found, data
will be an empty object.
interface GetPlaceResponse {
data: Place;
}
data
contains aPlace
object.interface Place { street_number?: string; street?: string; street2?: string; subpremise?: string; neighborhood?: string; city?: string; sublocality_level_1?: string; sublocality_level_2?: string; sublocality_level_3?: string; sublocality_level_4?: string; region_code?: string; county?: string; country_code?: string; postal_code?: string; premise?: string; lat?: number; latitude?: number; long?: number; longitude?: number; }
- The properties on
Place
are all dependent on where in the world the place is. Here is one example:{ city: "New York", country_code: "US", county: "New York", lat: 40.7507042, latitude: 40.7507042, long: -73.9937515, longitude: -73.9937515, postal_code: "10001", region_code: "NY", street: "4 Pennsylvania Plaza", sublocality_level_1: "Manhattan" }
- The properties on
Error Handling
The SDK does no special error handling for this GET request. On a network error, it will simply throw the Error
object that fetch
would throw.