in packages/pressreader/src/processEdition.ts [223:248]
async function fetchFrontData(
front: FrontSource,
): Promise<FrontSourceWithData | undefined> {
const response = await fetch(front.sectionContentURL);
if (response.status != 200) {
console.log(
`Front source error [${response.status}]: ${front.sectionContentURL}`,
);
return undefined;
}
const data = (await response.json()) as unknown;
if (!isPressedFrontPage(data)) {
console.log(
`Front source returned invalid response: ${front.sectionContentURL}`,
);
return undefined;
}
if (data.collections.length === 0) {
console.log(`Front source has no collections: ${front.sectionContentURL}`);
return undefined;
}
return {
...front,
data,
};
}