I am using a headless CMS and getting the data like below.
---
const res = await fetch(`${url}?${query}`, {
headers: headers,
});
const json = await res.json();
---
This works fine, but I'd like to have this data in multiple pages and I don't want to fetch each time due to the headless CMS access count.
I've come up with an idea to make an endpoint so that the pages that need the API data can get it "after" the build. But I believe that is kind of ruining the pros of Astro/SSG.
Is there any way to get the fetched data at build time for multiple pages only once?