У меня две проблемы:
Первая проблема: я не могу выполнить асинхронную функцию:
let address = req.body.merchant_address;
let location = getGeolocation(address);
console.log(location);
async function getGeolocation(address) {
try {
const res = await googleMapsClient.geocode({ address: address }).asPromise();
const location = res.json.results[0].geometry.location;
console.log(location)
return location;
} catch (e) {
return res.status(422).json({
err: err
});
}
}
Сначала печатается Promise { <pending> }
, а затем только мои координаты, что я сделал не так?в приведенном выше коде?
import maps from '@google/maps';
const googleMapsClient = maps.createClient({
key: 'my key'
});
Вторая проблема.Когда я строю проект, после запуска выдается ошибка Error: Can not find the module '@ google / maps
.Я компилирую проект, используя babel src --out-dir backend
в package.json file
.Почему он не видит "@ google/maps"
?