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

client.reverseGeocode throws TypeError: this.getEphemeralKeyInfo is not a function #894

Open
marcodiloreto opened this issue Nov 22, 2022 · 4 comments
Assignees
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

@marcodiloreto
Copy link

marcodiloreto commented Nov 22, 2022

Im unable to use the Client.reverseGeocode correctly, I've juggled around with the request object's preperties to no result =(.

I'm using the library within a NestJs server. Judging by the error log, since the exception is thrown within the google maps package, i'm confident its an issue with the library, perhaps im wrong?...
heres the code

import { Client, Language} from "@googlemaps/google-maps-services-js";
import { Injectable } from '@nestjs/common';

@Injectable()
class GoogleApiService {

  constructor(private readonly client: Client) {}

  async autocompletePlaces(text: string, lat: number, lng: number) {
  this.client.autocomplete(/* works!! */)
  }

  async geocode(place: string) {
  this.client.geocode(/* works!! */)
  }

  async reverseGeocode(lat: number, lng: number) {
        return this.client.reverseGeocode({
            params: {
                language: Language.es,
                latlng: { lat, lng },
                key: process.env.GOOGLE_API_KEY,
            },
            method: 'GET'
        })

    }
  }
}

and this is the error log, i've put this arrows "--->" in lines i deemed important

ERROR [ExceptionsHandler] this.getEphemeralKeyInfo is not a function
--->TypeError: this.getEphemeralKeyInfo is not a function
    at Object.onConnectSecure [as secure] (node:_tls_wrap:1523:25)
    at TransformOperationExecutor.transform (C:\Users\marco\Desktop\nest-sagi-app\node_modules\src\TransformOperationExecutor.ts:207:39)
    at TransformOperationExecutor.transform (C:\Users\marco\Desktop\nest-sagi-app\node_modules\src\TransformOperationExecutor.ts:327:31)
    at C:\Users\marco\Desktop\nest-sagi-app\node_modules\src\TransformOperationExecutor.ts:79:30
    at Array.forEach (<anonymous>)
    at TransformOperationExecutor.transform (C:\Users\marco\Desktop\nest-sagi-app\node_modules\src\TransformOperationExecutor.ts:44:24)
    at TransformOperationExecutor.transform (C:\Users\marco\Desktop\nest-sagi-app\node_modules\src\TransformOperationExecutor.ts:327:31)
    at TransformOperationExecutor.transform (C:\Users\marco\Desktop\nest-sagi-app\node_modules\src\TransformOperationExecutor.ts:327:31)
    at TransformOperationExecutor.transform (C:\Users\marco\Desktop\nest-sagi-app\node_modules\src\TransformOperationExecutor.ts:327:31)
    at TransformOperationExecutor.transform (C:\Users\marco\Desktop\nest-sagi-app\node_modules\src\TransformOperationExecutor.ts:327:31)

---> C:\Users\marco\Desktop\nest-sagi-app\node_modules\@googlemaps\google-maps-services-js\node_modules\axios\lib\adapters\http.js:70     
--->var data = config.data;
                      ^
--->TypeError: Cannot read properties of undefined (reading 'data')
--->at dispatchHttpRequest (C:\Users\marco\Desktop\nest-sagi-app\node_modules\@googlemaps\google-maps-services-js\node_modules\axios\lib\adapters\http.js:70:23)
    at new Promise (<anonymous>)
    at Object.httpAdapter [as adapter] (C:\Users\marco\Desktop\nest-sagi-app\node_modules\@googlemaps\google-maps-services-js\node_modules\axios\lib\adapters\http.js:49:10)
    at C:\Users\marco\Desktop\nest-sagi-app\node_modules\@googlemaps\google-maps-services-js\src\adapter.ts:56:8
    at new Promise (<anonymous>)
    at Object.customAdapter [as adapter] (C:\Users\marco\Desktop\nest-sagi-app\node_modules\@googlemaps\google-maps-services-js\src\adapter.ts:54:3)
    at TransformOperationExecutor.transform (C:\Users\marco\Desktop\nest-sagi-app\node_modules\src\TransformOperationExecutor.ts:207:    at TransformOperationExecutor.transform (C:\Users\marco\Desktop\nest-sagi-app\node_modules\src\TransformOperationExecutor.ts:327:31)    at ClassTransformer.instanceToPlain (C:\Users\marco\Desktop\nest-sagi-app\node_modules\src\ClassTransformer.ts:25:21)
    at Object.classToPlain (C:\Users\marco\Desktop\nest-sagi-app\node_modules\src\index.ts:23:27)

im working with

"@googlemaps/google-maps-services-js": "^3.3.16",

i really apreciate any help i cant get

@marcodiloreto marcodiloreto 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 Nov 22, 2022
@marcodiloreto
Copy link
Author

hello?

@amuramoto
Copy link
Member

are you still seeing this issue?

@vikingprank
Copy link

vikingprank commented Jul 17, 2023

Did you ever find a solution? I'm on NestJs as well. I'm logging the axios query that gives me the getEphemeralKeyInfo error and there doesn't seem to be any issue with it but the response is undefined:

httpAdapter config {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
adapter: [Function: customAdapter],
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 10000,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
env: {
FormData: [Function: FormData] {
LINE_BREAK: '\r\n',
DEFAULT_CONTENT_TYPE: 'application/octet-stream'
}
},
validateStatus: [Function: validateStatus],
headers: {
Accept: 'application/json, text/plain, /',
'User-Agent': 'google-maps-services-node-3.3.33',
'Accept-Encoding': 'gzip'
},
httpsAgent: HttpsAgent {
_events: [Object: null prototype] {
free: [Array],
newListener: [Function: maybeEnableKeylog]
},
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 443,
protocol: 'https:',
options: [Object: null prototype] {
keepAlive: true,
freeSocketTimeout: 4000,
timeout: 8000,
socketActiveTTL: 0,
path: null
},
requests: [Object: null prototype] {},
sockets: [Object: null prototype] {},
freeSockets: [Object: null prototype] {},
keepAliveMsecs: 1000,
keepAlive: true,
maxSockets: Infinity,
maxFreeSockets: 256,
scheduling: 'lifo',
maxTotalSockets: Infinity,
totalSocketCount: 0,
createSocketCount: 0,
createSocketCountLastCheck: 0,
createSocketErrorCount: 0,
createSocketErrorCountLastCheck: 0,
closeSocketCount: 0,
closeSocketCountLastCheck: 0,
errorSocketCount: 0,
errorSocketCountLastCheck: 0,
requestCount: 0,
requestCountLastCheck: 0,
timeoutSocketCount: 0,
timeoutSocketCountLastCheck: 0,
maxCachedSessions: 100,
_sessionCache: { map: {}, list: [] },
[Symbol(kCapture)]: false,
[Symbol(agentkeepalive#currentId)]: 0
},
params: {
input: '34 rue longue',
key: 'XXXXXXXXXXXXXXXXXXXXX'
},
method: 'get',
url: 'https://maps.googleapis.com/maps/api/place/autocomplete/json',
paramsSerializer: [Function (anonymous)],
data: undefined
}

@vikingprank
Copy link

After tinkering for a few hours, I was able to get things to work by simply using
import { HttpService } from '@nestjs/axios';
and writing my custom api calls instead of using the google-maps-services-js library

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

3 participants