all repos — caroster @ 6b8abc9e05f8c02edd810b82920a1b29398c83bd

[Octree] Group carpool to your event https://caroster.io

frontend/lib/getPlacesSuggestion.ts (view raw)

 1interface Params {
 2  search: string;
 3  proximity?: string;
 4  locale: string;
 5}
 6
 7export interface PlaceSuggestion {
 8  place_name: string;
 9  center: [number, number];
10}
11
12const getPlacesSuggestions = async ({
13  search,
14  proximity,
15  locale,
16}: Params): Promise<Array<PlaceSuggestion>> => {
17  const suggestions = await fetch(
18    '/api/mapbox/places?' +
19      new URLSearchParams({
20        search,
21        proximity,
22        locale,
23      })
24  )
25    .then(res => res.json())
26    .catch(console.error);
27
28  return suggestions;
29};
30
31export default getPlacesSuggestions;