Replies: 2 comments
-
|
You're right, iirc the onError callback is only used for "failed to load script" type errors. For the API key, we're handling that case as well, but it's not very elegant: You can use the Note that the key verification happens after the API has been successfully loaded (not sure when exactly, I think it might be when a map-instance is being created). See here for the implementation: react-google-maps/src/libraries/google-maps-api-loader.ts Lines 166 to 169 in b9760e9 |
Beta Was this translation helpful? Give feedback.
-
|
Yes, you can detect an invalid API key using the const { status } = useApiLoaderStatus();
if (status === APILoadingStatus.AUTH_FAILURE) {
// API key is invalid - handle error here
}Alternatively, you can listen to changes using the const status = useApiLoaderStatus();
useEffect(() => {
if (status === APILoadingStatus.AUTH_FAILURE) {
// Call your callback function
handleApiKeyError();
}
}, [status]);This approach gives you full control over how to respond to API key validation failures in your application. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is it possible to get a callback to fire when the API key is invalid? The provider has an onError callback, but that does not seem to be triggered if the error is an invalid API key
Beta Was this translation helpful? Give feedback.
All reactions