fix: fetch timeout for external requests to small (#881)

* fix: fetch timeout for external requests to small

* fix: format issue

* fix: move clear timeout for fetch to finally
This commit is contained in:
Meier Lukas authored and GitHub committed 2024-07-29 06:30:56 +02:00
1 parent 406ed16ce4
commit 67dad45214
9 files changed
+34 -7

No files matched your search

+2 -1
View File
@@ -1,3 +1,4 @@
import { fetchWithTimeout } from "@homarr/common";
import type { z } from "@homarr/validation";
import { validation } from "@homarr/validation";
@@ -8,7 +9,7 @@ export const locationRouter = createTRPCRouter({
.input(validation.location.searchCity.input)
.output(validation.location.searchCity.output)
.query(async ({ input }) => {
const res = await fetch(`https://geocoding-api.open-meteo.com/v1/search?name=${input.query}`);
const res = await fetchWithTimeout(`https://geocoding-api.open-meteo.com/v1/search?name=${input.query}`);
return (await res.json()) as z.infer<typeof validation.location.searchCity.output>;
}),
});