• Instructions to Ask a Question

    For any assistance, please click the "Ask a Question" button and select the Pabbly product for which you require support.

    We offer seven comprehensive applications designed to help you efficiently manage and grow your business:

    Our support team endeavors to respond within 24 business hours (Monday to Friday, 10:00 AM to 6:00 PM IST). We appreciate your understanding and patience.

  • Due to Holi celebrations, our team will have limited availability. While we’ll continue to monitor threads, responses may be slightly delayed.

Trying to write the JS code to calculate distance between 2 address

Can you please modify and let me know what code I have to put to calculate distance between 2 address using "Code" I have written the following code but it is giving and error :You cannot import node modules or use eval() in your code. We have already imported Node modules like 'crypto-js', 'lodash', and 'moment' into the wrapper function for you. To use them call these predefined variables: CryptoJS, _, moment respectively.

Is it possible to provide this some how if you don't like me putting this code

const AWS = require('aws-sdk');
const https = require('https');

const address1 = "New York City, NY";
const address2 = "Los Angeles, CA"; const url = `https://maps.googleapis.com/maps/api/distancematrix/json?origins=${address1}&destinations=${address2}&key=YOUR_API_KEY`;
https.get(url, (res) => {
res.on('data', (data) => {
const response = JSON.parse(data);
const distance = response.rows[0].elements[0].distance.text;
console.log(`The distance between ${address1} and ${address2} is ${distance}.`);
});
});

Note: I have put my google API but it's still not working
 
Top