I am trying to creation a distance form but I can’t get the result of fetch(url) result i am using this syntaxe
in backend Module :
import { fetch } from 'wix-fetch';
export function getDistance(origin, destination) {
var googleMapsDistnace = 'https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=' + origin.formatted + '&destinations=' + destination.formatted + '&key=MyGoogleMapsKey';
console.log(googleMapsDistnace);
let result;
result = fetch(googleMapsDistnace, {method:'get'}).then((respense) => {
return respense.json();
}).then((json) => {
return json;
})
return result;
}
In frontend :
export function button_click(event) {
result = getDistance(start, end)
// console.log('result');
console.log(result);
}
my resulte :
I wanna get only:
result = Promise.[[PromiseValue]]