Skip to content
Discussion options

You must be logged in to vote

Yes, you can detect an invalid API key using the useApiLoaderStatus() hook as mentioned above. Once the API has been loaded, check the APILoadingStatus value:

const { status } = useApiLoaderStatus();

if (status === APILoadingStatus.AUTH_FAILURE) {
  // API key is invalid - handle error here
}

Alternatively, you can listen to changes using the useApiLoaderStatus() hook with a useEffect to trigger a callback whenever the status changes:

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 valid…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by usefulthink
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants