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

placesNearby() gives INVALID_REQUEST when params are correct #1306

Open
boob1e opened this issue Jan 19, 2025 · 1 comment
Open

placesNearby() gives INVALID_REQUEST when params are correct #1306

boob1e opened this issue Jan 19, 2025 · 1 comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@boob1e
Copy link

boob1e commented Jan 19, 2025

Environment details

  1. Places
  2. Mac OS 15.2
  3. 3.4.0

Steps to reproduce

  1. Snippet below gives invalid request even when providing necessary lat and long with valid API key. I've tried with the array, an object with lat/lng, as well as an object with latitude/longitude. None appear to give me a successful response. If I try to use other functions like elevation from the example here I can get a 200 back.

Code example

const response = await client.placesNearby({
      params: {
        location: [0, 0],
        key: '<API_KEY>',
      },
    });

Stack trace

"AxiosError: Request failed with status code 400\n    at settle (webpack-internal:///(action-browser)/./node_modules/@googlemaps/google-maps-services-js/dist/adapter.js:60:16)\n    at eval (webpack-internal:///(action-browser)/./node_modules/@googlemaps/google-maps-services-js/dist/adapter.js:81:13)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at Axios.request (webpack-internal:///(action-browser)/./node_modules/axios/dist/node/axios.cjs:4252:41)\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async getNearbyGyms (webpack-internal:///(action-browser)/./src/actions/gym.ts:29:26)\n    at async /Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:157:2088\n    at async handleAction (/Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:156:21940)\n    at async renderToHTMLOrFlightImpl (/Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:161:22192)\n    at async doRender (/Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/server/base-server.js:1565:34)\n    at async responseGenerator (/Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/server/base-server.js:1813:28)\n    at async DevServer.renderToResponseWithComponentsImpl (/Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/server/base-server.js:1823:28)\n    at async DevServer.renderPageComponent (/Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/server/base-server.js:2250:24)\n    at async DevServer.renderToResponseImpl (/Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/server/base-server.js:2288:32)\n    at async DevServer.pipeImpl (/Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/server/base-server.js:959:25)\n    at async NextNodeServer.handleCatchallRenderRequest (/Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/server/next-server.js:281:17)\n    at async DevServer.handleRequestImpl (/Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/server/base-server.js:853:17)\n    at async /Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/server/dev/next-dev-server.js:371:20\n    at async Span.traceAsyncFn (/Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/trace/trace.js:153:20)\n    at async DevServer.handleRequest (/Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/server/dev/next-dev-server.js:368:24)\n    at async invokeRender (/Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/server/lib/router-server.js:230:21)\n    at async handleRequest (/Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/server/lib/router-server.js:408:24)\n    at async requestHandlerImpl (/Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/server/lib/router-server.js:432:13)\n    at async Server.requestListener (/Users/tommypickles/Developer/pump-buddy/node_modules/next/dist/server/lib/start-server.js:146:13)"
@boob1e boob1e added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jan 19, 2025
@boob1e
Copy link
Author

boob1e commented Jan 20, 2025

Looks like there's things marked as optional that are not optional. At a minimum radius is required. Also this note doesn't seem correct * Note that `radius` must not be included if `rankby=distance` is specified.

https://developers.google.com/maps/documentation/places/web-service/search-nearby#maps_http_places_nearbysearch-txt

Using a standard http request including radius I was able to get a 200 back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

1 participant