1
0

Create an app to search menus

This commit is contained in:
rui hildt
2024-05-08 18:08:21 +02:00
commit 55fd2993f3
16 changed files with 31896 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
// place files you want to import through the `$lib` alias in this folder.
export const debounce = (callback: Function, wait = 300) => {
let timeout: ReturnType<typeof setTimeout>
return (...args: any[]) => {
clearTimeout(timeout)
timeout = setTimeout(() => callback(...args), wait)
}
}
File diff suppressed because one or more lines are too long
+27968
View File
File diff suppressed because it is too large Load Diff
+20
View File
@@ -0,0 +1,20 @@
export interface OSMNominatimPlace {
addresstype: string
boundingbox: number[]
class: string
display_name: string
lat: string
lon: string
name: string
type: string
}
export const getLocations = async (query: string): Promise<OSMNominatimPlace[]> => {
const url = `https://nominatim.openstreetmap.org/search?q=${query}&limit=10&format=json`
const response = await (await fetch(url)).json()
const locations = response as OSMNominatimPlace[]
return locations
}