#Why does the content layer API fetch data twice

3 messages · Page 1 of 1 (latest)

drifting depot
#

I've created a custom loader and I'm noticing the content layer API fetches the data twice. Is this expected behavior?

floral auroraBOT
#

Hi @drifting depot. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the knowledge sources provided, there isn't specific information about the Content Layer API fetching data twice or why this might occur. The documentation doesn't mention this behavior as an expected or common issue.

However, it's worth noting that the Content Layer API is a relatively new feature in Astro, introduced in version 5.0. If you're experiencing unexpected behavior, it could potentially be related to how your custom loader is implemented or how it interacts with Astro's build process.

To better understand and potentially resolve this issue, you might want to:

  1. Double-check your custom loader implementation to ensure it's not inadvertently triggering multiple data fetches.

  2. Consider using the refreshContent function, which is part of the astro:server:setup hook. This function is designed to update the content layer during development and might provide more control over when data is fetched Astro Integration API.

  3. Review the full Content Loader API documentation to ensure your loader is implemented correctly and efficiently.

If the issue persists, it would be advisable to seek help from the Astro community or report it as a potential bug, as the behavior you're describing is not explicitly mentioned in the provided documentation.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: