Skip to content

Instantly share code, notes, and snippets.

@eamonnboyle
Created February 23, 2021 10:24
Show Gist options
  • Save eamonnboyle/1ed825e6fc273a3cfd4f2f29b2679881 to your computer and use it in GitHub Desktop.
Save eamonnboyle/1ed825e6fc273a3cfd4f2f29b2679881 to your computer and use it in GitHub Desktop.
Weather App Tutorial - Search Service
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