Autocompletionservice.getpredictions: failed to load resource: net::ERR_INTERNET_DISCONNECTED

ramesh penta 0 Reputation points

I had develop the web application for google map api address search

<script src="" async defer></script>                                      

This is googlemap api url

when search the address I had called initAutocomplete callback

`window.initAutocomplete = function (searchText, compoent, name) { try { const strictBoundsInputElement = document.getElementById( "use-strict-bounds" ); const options = { fields: ["formatted_address", "address_components", "geometry", "name"], strictBounds: false, types: ["premise"], };

    if (name == "Ordering")
        var autocomplete = new google.maps.places.Autocomplete($("#autocomplete")[0], { options, strictBoundsInputElement });

    autocomplete.setComponentRestrictions({ 'country': ['uk'] });

    const infowindow = new google.maps.InfoWindow();
    const infowindowContent = document.getElementById(

    const marker = new google.maps.Marker({

        anchorPoint: new google.maps.Point(0, -29),
    google.maps.event.addListener(autocomplete, 'place_changed', function (e) {

        place = autocomplete.getPlace();
        if (!place.geometry || !place.geometry.location) {
            window.alert("No details available for input: '" + + "'");


        var street_addr = autocomplete.getPlace().formatted_address;
        var latitude = autocomplete.getPlace();
        var langitude = autocomplete.getPlace().geometry.location.lng();
        var placeResult = autocomplete.getPlace();
        var addressComponents = placeResult.address_components;
        var street = "";
        var number = "";
        var premise = "";
        var postalcode = "";
        var administrative_area_level_1 = "";
        var administrative_area_level_2 = "";
        var locality = "";
        var postal_town = "";
        var country = "";

catch (error) {
    // Call the error callback function and pass the error message


#autocomplete is textbox when internet not have i.e offline at the time if we search the address , this api failed fetch that means Failed to load resource: net::ERR_INTERNET_DISCONNECTED . This error find on browser console. I am unable to catch this exception on scriptside using catch block. I want to handle this exception if failed to feacth the api then i want to show user friendly message to enduser. How will handle properly and show the user fridenly message`

JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
905 questions
0 comments No comments
{count} votes