react-places-autocomplete
react-places-autocomplete copied to clipboard
Fetch Zip Code
trafficstars
Is there any way to fetch the zipcode of the current address? kindly let me know ASAP thank u.
You can use the geoCodeByPlaceId helper to grab the full location on select.
const onSuggestionSelect = async (address, placeId, suggestion) => {
const [place] = await geocodeByPlaceId(placeId);
const {long_name:postalCode = ''} = place.address_components.find( c => c.types.includes('postal_code')) || {};
console.log(postalCode);