Skip to content

placesService.getDetails is undefined #233

Open

Description

@isaacfink

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

Activity

  1. ozergul commented on Apr 16, 2024

    @ozergul

    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]
  2. jamesofficer commented on Apr 23, 2024

    @jamesofficer

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions