bhutanigaurav
Member
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
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