JSFiddle - React, Tailwind, and code Playground

HTML

<script src=" http://maps.googleapis.com/maps/api/js?v=3&amp;amp;sensor=false&amp;libraries=places"></script>
<input id="location" name="location" placeholder="Please Enter Location and hit ENTER">
<div id="map-canvas"></div>

CSS

input {
    padding: 10px;
    width: 80%;
}

JavaScript

geocoder = new google.maps.Geocoder();

function codeAddress() {
    var address = document.getElementById('location').value;
    geocoder.geocode({
        'address': address
    }, function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            
           /*
            * HERE IS WHAT YOU WANT
           */
           alert(results[0].address_components);
           var yourVariable = results[0].address_components;
            
            
            
        } else {
            alert('Geocode was not successful for the following reason: ' + status);
        }
    });
}


document.getElementById('location').onkeyup = function (e) {
    if (e.which === 13) {
        codeAddress();
    }
}