Skip to content

Commit

Permalink
Nouveau importateur
Browse files Browse the repository at this point in the history
  • Loading branch information
julienmalard committed Oct 15, 2023
1 parent b94d01b commit 7f8306c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/importateur/epicollecte.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import axios from "axios";
import { élémentDic } from "./json.js";

export const importerDonnéesEpiCollecte = async ({ idProjet, instance = "https://five.epicollect.net" }: {idProjet: string, instance: string}): Promise<élémentDic[]> => {
const urlBase = `${instance}/api/export/entries/${idProjet}`
const réponseBase = (await axios.get(urlBase)).data;
const nPages = réponseBase["meta"]["last_page"]
let données: élémentDic[] = [];
for (const i in Array(nPages).keys()) {
const urlPage = `${instance}/api/export/entries/${idProjet}?page=${i+1}`
données = [...données, ...(await axios.get(urlPage)).data["data"]["entries"]];
}
return données
}

0 comments on commit 7f8306c

Please sign in to comment.