how show map API key invalid

15 views Asked by At

I get API key from client side, I want check API key is valid or not (javascript,react js)

useEffect(() => { const script = document.createElement('script'); script.src = https://maps.googleapis.com/maps/api/js?key="API_key"&libraries=geometry,drawing,places; script.async = true; script.defer = true;

    script.onload = () => {
        setIsMapLoaded(true);
    };

    script.onerror = () => {
        console.log("invalid")
    };

    document.head.appendChild(script);
    return () => {
        document.head.removeChild(script);
    };
}, []);
0

There are 0 answers