We have an application that depends on Google maps distance matrix API to calculate distance and time between two points. It's a nodejs application. We have been using this Google Maps Node.js Client
The application has been working okay. Now it times out. We have accepted the new pricing and terms of service that got into effect since July 16, added a billing account as well as generate a new key. We thought that could be the case but we are still getting a timeout error.
Our code is as follows:
const googleMaps = require("@google/maps");
let mapsClient = googleMaps.createClient({
key: process.env.GOOGLE_MAPS_KEY,
Promise: Promise
});
mapsClient.distanceMatrix({
origins: fromLat + ',' + fromLng,
destinations: toLat + ',' + toLng,
mode: 'driving'
}).asPromise().then(res => {
// Do something in case of success
}).catch(err => {
// Do something else in case of error
console.log('MAPS ERROR', err); // Prints out a timeout
});
I cannot figure out what we are doing wrong. Logging the error on catch prints out timeout. Please help.