In my loop I have to get the address of lat and long. I have this function using reverseGeolocation
_getLocationAddress = async location => {
return new Promise((resolve, reject) => {
try {
const { status, data } = await srs.getReverseGeolocation(location);
if (data) {
resolve(data.results[0].formatted_address);
}
} catch (err) {
console.log(err);
reject(err);
}
});
};
I also tried not wrapping into promise and not async it doesn't work it keeps returning a promise object. What I need from there is to return the data result into string. Here's my render
renderNewSR() {
const { delivery_items } = this.state;
return delivery_items.map((prop, key) => {
const location = {
latitude: parseFloat(prop.pickuplat),
longitude: parseFloat(prop.pickuplong)
};
//console.log(location);
const address = "";
this._getLocationAddress(location)
.then(res => {
console.log(res);
})
.catch(err => {
console.log(err);
});
.....
What is alternative solution to this. I want the result from google api return as string and can be displayed in render.