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

[Google Maps Places API] - Text Search missing next_page_token in response #5385

Open
shaunmitchellve opened this issue May 24, 2024 · 11 comments
Assignees

Comments

@shaunmitchellve
Copy link

  • which product (packages/*): packages/google-maps-places
  • OS: OSX
  • Node.js version: 21.7.2
  • npm version: 10.6.0
  • google-cloud-node version:Place2 1.6.0

Steps to reproduce

  • npm i @googlemap/places
const {PlacesClient} = require('@googlemaps/places').v1;

 let response = await placesClient.searchText(textQuery: 'something', {
 otherArgs: {
  headers: {
   'x-Goog-FieldMask': 'places.displayName',  
},}});

console.log(response);

/*
response:
[
  {
    places: [
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object]
    ],
    contextualContents: []
  },
  null,
  null
]

I would expect something like:
[
  {
    places: [
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object]
    ],
    contextualContents: [],
    nextPageToken: ''
  },
  null,
  null
]
*/
@alturda
Copy link

alturda commented Jun 7, 2024

can confirm this is a huge issue

@richardmarchant
Copy link

I can confirm this too, "nextPageToken" is never included.

@sofisl sofisl self-assigned this Jul 18, 2024
@sofisl sofisl added the needs more info This issue needs more information from the customer to proceed. label Jul 18, 2024
@sofisl
Copy link
Contributor

sofisl commented Jul 18, 2024

see

Can you try setting autoPaginate: false or using the Async method?

@shaunmitchellve
Copy link
Author

Adding in the autoPagination: false into the GAX options doesn't seem to work, unless I'm doing it wrong

import {PlacesClient} from '@googlemaps/places';

const placesClient = new PlacesClient();

const response = await placesClient.searchText(
{
    textQuery: 'something',
    pageSize: 10,
},
{
    autoPaginate: false,
    otherArgs: {
        headers: {
        'X-Goog-FieldMask': 'places.id,places.displayName',
        },
    },
});

console.log('Places: ', response);
// RESPONSE
Places:  [
  {
    places: [
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object]
    ],
    contextualContents: []
  },
  null,
  null
]
import {PlacesClient} from '@googlemaps/places';

const placesClient = new PlacesClient();

const [resultArray, nextPageRequest, rawRespone] = await placesClient.searchText(
{
    textQuery: 'schools in Calgary Alberta',
},
{
    autoPaginate: false,
    otherArgs: {
        headers: {
        'X-Goog-FieldMask': 'places.id,places.displayName',
        },
    },
});

console.log("RESULTS:", resultArray);
console.log("NEXT PAGE: ", nextPageRequest);
console.log("RAW: ", rawRespone);
 

//RESPONSE:
RESULTS: {Places:  [
  {
    places: [
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object]
    ],
    contextualContents: []
  }
]
}

NEXT PAGE:  null
RAW:  null

Also, there doesn't appear to be any searchTextAsync function definition so it errors out when attempting to use that approach.

@github-actions github-actions bot removed the needs more info This issue needs more information from the customer to proceed. label Jul 18, 2024
@bscthartmann
Copy link

Yesterday it worked for me but today not. Also in the API Text on Google page, filled with the Demo from the page, the nextPageToken does not appear.

https://developers.google.com/maps/documentation/places/web-service/text-search?hl=en

The example from the page

 curl -X POST -d '{
  "textQuery": "pizza in New York",
  "pageSize": 5
  }' \
-H 'Content-Type: application/json' -H 'X-Goog-Api-Key: API_KEY' \
-H "X-Goog-FieldMask: places.id,nextPageToken" \
'https://places.googleapis.com/v1/places:searchText'

Makes it basically impossible to use this API :(

@LombaxTech
Copy link

Also having this issue. I'm sure it was working previously but no longer...

@probablykabari
Copy link

I concur with @bscthartmann that this seems to be broken in the API itself. This curl request from the documentation does not return a token as specified:

Docs

Reality
❯  curl -X POST -d '{
  "textQuery": "pizza in New York",
  "pageSize": 5
  }' \
-H 'Content-Type: application/json' -H 'X-Goog-Api-Key:  [API_KEY] \
-H "X-Goog-FieldMask: places.id,nextPageToken" \
'https://places.googleapis.com/v1/places:searchText'
{
  "places": [
    {
      "id": "ChIJifIePKtZwokRVZ-UdRGkZzs"
    },
    {
      "id": "ChIJ6xvs94VZwokRnT1D2lX2OTw"
    },
    {
      "id": "ChIJqcgHCJ1ZwokRRmJ-uWL5DAA"
    },
    {
      "id": "ChIJjaD94kFZwokR-20CXqlpy_4"
    },
    {
      "id": "ChIJmcyIPBVZwokRq8rnnNYek0w"
    }
  ]
}

@Hugh-Kane
Copy link

I can confirm—everything was working fine for me until around Sunday, August 25, 2024. However, my web app is now broken because the nextPageToken is no longer being returned in the API calls. I'm using the new Places API text search request (endpoint starting with https://places.googleapis.com/v1/places:searchText). I'm considering rolling back to the previous version of the Places API (endpoint starting with https://maps.googleapis.com/maps/api/place/textsearch). Can anyone confirm if the nextPageToken is still working with the older endpoint?"

@LombaxTech
Copy link

Unfortunately it is not working even with the older endpoint for me. I tried it but no token is returned in both version.

@Hugh-Kane
Copy link

Coming back to this thread - as it seems like I'm getting nextPageToken once again in my return as of today (31st Aug 2024)

@acaumartin-cameleon
Copy link

I can confirm that the nextPageToken is in the api call, but it's still not showing with PlacesClient

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

9 participants