<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="row">
<h2>Call Google api using request parameters in nodejs</h2>
</div>
</div>
const request = require("request");
let apiKey = 'AIzaSyDYrkvFvaOOB1bLLS40mTwHG2B5_G4t-c0';
let address = 'pinjore';
let targetUrl = `https://maps.googleapis.com/maps/api/geocode/json?address=${address}&key=${apiKey}`
request(targetUrl, function (err, response, body) {
console.log('error:', err); // prints the error if one occurred
let geoLocation = JSON.parse(body);
var latitide = `latitide: ${geoLocation.results[0].geometry.location.lat}`
var longitude= `longitude: ${geoLocation.results[0].geometry.location.lng}`
console.log(latitide,longitude);
});