Skip to content

Commit

Permalink
fix headers getter
Browse files Browse the repository at this point in the history
  • Loading branch information
folland87 committed Dec 9, 2024
1 parent 665ddc0 commit 749f9a2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/jobs/sirene/fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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)),
Expand Down

0 comments on commit 749f9a2

Please sign in to comment.