mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-21 11:20:17 -04:00
Add Places Search API
This commit is contained in:
parent
664753577b
commit
ce1fce23a9
15
src/api/google.ts
Normal file
15
src/api/google.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
export const GOOGLE_MAPS_API_KEY = 'AIzaSyDUnWIrt-H4RuP2YFLpVPz4oAjBhpOOoyI';
|
||||
|
||||
export async function searchForPlaces(query: string) {
|
||||
const url = new URL(
|
||||
'https://maps.googleapis.com/maps/api/place/findplacefromtext/json'
|
||||
);
|
||||
url.searchParams.set('key', GOOGLE_MAPS_API_KEY);
|
||||
url.searchParams.set('input', query);
|
||||
url.searchParams.set('inputtype', 'textquery');
|
||||
|
||||
let res = await fetch(url.toString());
|
||||
let json = await res.json();
|
||||
|
||||
return json;
|
||||
}
|
Loading…
Reference in New Issue
Block a user