Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

placesService.getDetails is undefined #233

Open
isaacfink opened this issue Mar 14, 2024 · 2 comments
Open

placesService.getDetails is undefined #233

isaacfink opened this issue Mar 14, 2024 · 2 comments

Comments

@isaacfink
Copy link

I am creating my instance like this

const {
        placePredictions,
        getPlacePredictions,
        isPlacePredictionsLoading,
        placesService
    } = useGoogle({
        apiKey: process.env.NEXT_PUBLIC_GOOGLE_PLACES_API_KEY,
    });

And calling the placesService like this

const getPlaceInfo = async (placeId) => {
        console.log(placesService)
        const info = await placesService.getDetails({ placeId })
    }

But in the console I see this {Fg: F$} and getDetails is undefined, I am not sure where this is coming from, it might have something to do with the bundler but it seems like the returned object is wrong

@ozergul
Copy link

ozergul commented Apr 16, 2024

use with useCallback and add placesService as deps. issue will be fixed.

  const getPlaceInfo = useCallback(async (placeId) => {
    console.log(placesService);
    const info = await placesService.getDetails({ placeId });
  }, [placesService]

@jamesofficer
Copy link

jamesofficer commented Apr 23, 2024

I resolved this by passing a callback as the second parameter.

placesService.getDetails({ placeId }, (response: any) => {
	console.log("response", response);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants