14 lines
466 B
TypeScript
14 lines
466 B
TypeScript
|
'use server'
|
||
|
|
||
|
import { LocationType } from "@/types/types";
|
||
|
|
||
|
export async function getLocation(searchLocation: string){
|
||
|
const placesKey = "AIzaSyBf1ip4XogdC6XmbfDhxS_RJDOSieycJpQ";
|
||
|
const url = `https://maps.googleapis.com/maps/api/geocode/json?${searchLocation}&key=${placesKey}`;
|
||
|
const res = await fetch(url);
|
||
|
if (!res.ok) {
|
||
|
throw new Error(`There was an error fetching the data`);
|
||
|
}
|
||
|
const data = await res.json();
|
||
|
return data;
|
||
|
}
|