"impots-react-app/vscode:/vscode.git/clone" n'existait pas sur "2d231a4f69b2688a223f747d741adb42f37f2e98"
Newer
Older
import { taxeStats } from "@/src/type/TaxeStats";
export const fetchTaxeData = async (taxe: string, year: number, metric: string): Promise<taxeStats[]> => {
const response = await fetch(
`https://localhost/${taxe}/stats?annee=${year}&groupBy=region&metric=${metric}`
);
if (!response.ok) {
throw new Error(`Erreur API pour l'année ${year}`);
}
const apiData = await response.json();
// On transforme le résultat pour qu'il corresponde à ton interface taxeStats
return apiData.member.map((d: any) => ({
region: d.label,
year: year,
value: d.value,
}));
};