Created
February 23, 2021 10:24
-
-
Save eamonnboyle/1ed825e6fc273a3cfd4f2f29b2679881 to your computer and use it in GitHub Desktop.
Weather App Tutorial - Search Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function searchLocation(term: string): Promise<WeatherLocation | undefined> { | |
const result = await fetch(`${server}/weather?q=${term}&${keyQuery}`); | |
if (result.status === 404) return undefined; | |
if (result.status !== 200) throw new Error('Failed to read location data'); | |
return await result.json(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment