google-maps-services-js
google-maps-services-js copied to clipboard
client.reverseGeocode throws TypeError: this.getEphemeralKeyInfo is not a function
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
hello?
are you still seeing this issue?
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 }
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