Closed nanduri1998 closed 4 years ago
Please add some additional information such as the error message and reopen this when you do.
Here is an e2e test that you can compare your code against: https://github.com/googlemaps/google-maps-services-js/blob/master/e2e/distance.test.ts
TypeError: o.map is not a function
at Object.origins (/srv/node_modules/@googlemaps/google-maps-services-js/dist/distance.js:18:21)
at Object.keys.forEach (/srv/node_modules/@googlemaps/google-maps-services-js/dist/serialize.js:90:42)
at Array.forEach (<anonymous>)
at /srv/node_modules/@googlemaps/google-maps-services-js/dist/serialize.js:88:29
at buildURL (/srv/node_modules/axios/lib/helpers/buildURL.js:31:24)
at dispatchHttpRequest (/srv/node_modules/axios/lib/adapters/http.js:84:13)
at new Promise (<anonymous>)
at httpAdapter (/srv/node_modules/axios/lib/adapters/http.js:21:10)
at dispatchRequest (/srv/node_modules/axios/lib/core/dispatchRequest.js:52:10)
at <anonymous>
This is the error I get, Deployed it using this lib on Firebase Cloud Functions.
My input is the following:
{ origin: 'burjuman', destination: 'ikea dubai' }
My code for this:
var origin = req.body.origin;
var destination = req.body.destination;
client.distancematrix({
params: {
origins: origin,
destinations: destination,
key: functions.config().google.key
}
}).then(data => {
console.log(data.data);
res.json(data.data);
}).catch(err => console.log(err));
client is the Google Maps constructor, The above code is executed in a Express App POST Call with input provided above (Removed redundant body check code and post params and function initiation).
The param should be an array.
origins: [origin],
destinations: [destination],
https://github.com/googlemaps/google-maps-services-js/blob/master/src/distance.ts#L48
The param should be an array.
origins: [origin], destinations: [destination],
https://github.com/googlemaps/google-maps-services-js/blob/master/src/distance.ts#L48
Got it. But please do update any documentation as it is very confusing.
Says can't perform map