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 :
![](https://static.wixstatic.com/media/a27d24_a2fabf3bc65d48fc9f99972c85279427~mv2.png/v1/fill/w_724,h_243,al_c,q_85,enc_auto/a27d24_a2fabf3bc65d48fc9f99972c85279427~mv2.png)
I wanna get only:
result = Promise.[[PromiseValue]]
Can someone help me please §
Note that a web module (backend code in a jsw file) returns a Promise which you will have to handle. See Calling a Function in a Web Module for more information.