OilĂ , I'm a beginner with nodejs and I am using it to create a telegram bot. This is my code:
const Geolocation = (req) => {
var address = "15 Freedom Way, Jersey City, NJ 07305, United States";
let msg = "";
let nodeGeocoder = require('node-geocoder');
let param = {
provider: 'openstreetmap'
};
let geoCoder = nodeGeocoder(param);
geoCoder.geocode(address)
.then((res) => {
msg = res[0].streetName;
})
.catch((err) => {
console.log(err);
});
console.log(msg);
return UTILS.formatDialogflowResponse(
msg,
[]
);
}
I would like it to keep the streetName
so that I can send it as a return response in UTILS.formatDialogflowResponse
I tried to write to a file and then read it just before sending, but every time it tends to first read the file, thus creating an error, and then write on it