import {ok, badRequest} from 'wix-http-functions'; export function getCoordinates(request) { const apiKey = "AIzaSyCfKuwMAdjCn_NiUjjwV005wojETDXAgPs"; const location = request.query.location; const apiUrl = `https://maps.googleapis.com/maps/api/geocode/json?address=${location}&key=${AIzaSyCfKuwMAdjCn_NiUjjwV005wojETDXAgPs}`; return fetch(apiUrl) .then(response => response.json()) .then(data => { const coordinates = data.results[0].geometry.location; return ok(coordinates); }) .catch(error => badRequest(error)); }
top of page
bottom of page