Create an app to search menus
This commit is contained in:
@@ -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
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user