System Information
- Strapi Version: 4.1.11
- Operating System: Xubuntu
- Database: Postgres
- Node Version:
- NPM Version:
- Yarn Version:
I use Strapi v4 and, when retrieving data from the frontend (Svelte) on http://localhost:3000/blog for example, with this code:
<script lang="ts" context="module">
import type { Load } from '@sveltejs/kit';
import { goto } from '$app/navigation';
export const load: Load = async ({ fetch }) => {
const res = await fetch(`${import.meta.env.VITE_BACKEND_URI}/api/posts?populate=*`);
const response = await res.json();
return { props: { posts: response.data } };
};
</script>
<script lang="ts">
export let posts: any;
console.log(posts);
</script>
I get this:
With all the correct nested data.
But then, when I click on each post, for example: http://localhost:3000/blog/second-chance and I try to retrieve the data with:
<script lang="ts" context="module">
import type { Load } from '@sveltejs/kit';
import { goto } from '$app/navigation';
export const load: Load = async ({ params, fetch }) => {
const res = await fetch(
`${import.meta.env.VITE_BACKEND_URI}/api/posts/${params.slug}?populate=*`
);
const response = await res.json();
return { props: { posts: response.data } };
};
</script>
<script lang="ts">
export let posts: any;
console.log('posts', posts);
</script>
I get this instead:
Where the fields author and localizations are missing (but not SEO, wich is strange).
Does someone know what could be happening?