From 749f9a27a7f531b84d8c56340a8429d371fd836d Mon Sep 17 00:00:00 2001 From: folland87 Date: Mon, 9 Dec 2024 11:20:11 +0100 Subject: [PATCH] fix headers getter --- src/jobs/sirene/fetcher.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/jobs/sirene/fetcher.js b/src/jobs/sirene/fetcher.js index e50452ee..2feac29e 100644 --- a/src/jobs/sirene/fetcher.js +++ b/src/jobs/sirene/fetcher.js @@ -5,8 +5,6 @@ const headers = { "X-INSEE-Api-Key-Integration": apiKey, }; -console.log(apiKey); - export const fetchSireneUpdates = async (startDate, endDate) => { const buildParams = (cursor) => new URLSearchParams({ @@ -21,14 +19,16 @@ export const fetchSireneUpdates = async (startDate, endDate) => { { headers }, ); const result = await response.json(); - console.log("fetchPage", response.status, JSON.stringify(response.headers)); + const nextCursor = response.headers.get("curseurSuivant"); + const total = response.headers.get("curseurSuivant"); + console.log("fetchPage", response.status, total, nextCursor); await new Promise((resolve) => setTimeout(resolve, 2100)); if (!result || response.status !== 200) { return []; } - return response.headers.curseurSuivant !== cursor + return nextCursor !== cursor ? [ ...result.etablissements, ...(await fetchPage(response.headers.curseurSuivant)),