interface Bulk {
data: { id: string; title: string | null }[];
pending: { id: string }[];
unfetched: { id: string; code: string; retry_after: number }[];
not_found: { id: string }[];
}
const res = await fetch('https://api.alura.io/v1/research/products?ids=4524717183,1587263044', {
headers: { Authorization: `Bearer ${process.env.ALURA_API_KEY}` },
});
if (!res.ok) throw new Error(`${res.status}: ${await res.text()}`);
const result = (await res.json()) as Bulk;
for (const p of result.data) console.log(`known: ${p.id} ${p.title}`);
for (const p of result.pending) console.log(`being fetched, ask again later: ${p.id}`);
for (const p of result.unfetched) console.log(`not fetched (${p.code}), retry in ${p.retry_after}s: ${p.id}`);
for (const p of result.not_found) console.log(`not found: ${p.id}`);