diff --git a/src/rest/resources/varselResource.tsx b/src/rest/resources/varselResource.tsx index 90b8ab008..db26b5141 100644 --- a/src/rest/resources/varselResource.tsx +++ b/src/rest/resources/varselResource.tsx @@ -1,8 +1,10 @@ import { apiBaseUri } from '../../api/config'; import { useFodselsnummer } from '../../utils/customHooks'; import { useQuery, UseQueryResult } from '@tanstack/react-query'; -import { FetchError, get } from '../../api/api'; +import { FetchError, get, post } from '../../api/api'; import { VarslerResult } from '../../models/varsel'; +import useFeatureToggle from '../../components/featureToggle/useFeatureToggle'; +import { FeatureToggles } from '../../components/featureToggle/toggleIDs'; function queryKey(fnr: string): [string, string] { return ['varsel', fnr]; @@ -12,10 +14,15 @@ function url(fnr: string): string { return `${apiBaseUri}/v2/varsler/${fnr}`; } +function urlV2(): string { + return `${apiBaseUri}/v2/varsler`; +} const resource = { useFetch(): UseQueryResult { const fnr = useFodselsnummer(); - return useQuery(queryKey(fnr), () => get(url(fnr))); + const { isOn } = useFeatureToggle(FeatureToggles.IkkeFnrIPath); + + return useQuery(queryKey(fnr), () => (isOn ? post(urlV2(), fnr) : get(url(fnr)))); } }; export default resource;