• 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.

    🚀 Exclusive Lifetime Offers 🚀

    We invite you to take advantage of our special one-time payment plans, providing lifetime access to select applications:

    • 🔥 Pabbly Connect — Lifetime Access for $249View Offer
    • 🔥 Pabbly Subscription Billing — Lifetime Access for $249View Offer
    • 🔥 Pabbly Chatflow — Lifetime Access for $249View Offer

    Make a one-time investment and enjoy the advantages of robust business management tools for years to come.

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