diff --git a/frontend/src/components/FilterButton.tsx b/frontend/src/components/FilterButton.tsx index 054ba132..6fa99edc 100644 --- a/frontend/src/components/FilterButton.tsx +++ b/frontend/src/components/FilterButton.tsx @@ -1,9 +1,10 @@ "use client"; -import { useRouter, useSearchParams } from "next/navigation"; +import { usePathname, useRouter, useSearchParams } from "next/navigation"; import { useState } from "react"; export default function FilterButton({ filterName }: { filterName: string }) { const router = useRouter(); + const pathname = usePathname(); const searchParams = useSearchParams(); const [isButtonActive, setIsButtonActive] = useState(checkFilterInUrl); @@ -21,7 +22,7 @@ export default function FilterButton({ filterName }: { filterName: string }) { newFilters.splice(filterIndex, 1); } const newFilterString = newFilters.join(",").replace(/^,/, ""); - router.push(`/bemanning?search=${currentSearch}&filter=${newFilterString}`); + router.push(`${pathname}?search=${currentSearch}&filter=${newFilterString}`); } function checkFilterInUrl() { diff --git a/frontend/src/data/fetchWithToken.ts b/frontend/src/data/fetchWithToken.ts index 55fb36f6..f574410f 100644 --- a/frontend/src/data/fetchWithToken.ts +++ b/frontend/src/data/fetchWithToken.ts @@ -26,8 +26,13 @@ export async function fetchWithToken(path: string): Promise { method: "GET", headers: headers, }; - const response = await fetch(`${apiBackendUrl}/${path}`, options); - return (await response.json()) as T; + try{ + const response = await fetch(`${apiBackendUrl}/${path}`, options); + return (await response.json()) as T; + } catch (e) { + console.log(`${apiBackendUrl}/${path}`) + console.error(e) + } } function mockedCall(path: string): Promise {