Ok I managed to do it with await blocks from Svelte :
<script>
async function getArticles() {
const res = await fetch(`http://localhost:1337/api/articles`);
const text = await res.json();
if (res.ok) {
return text;
} else {
throw new Error(text);
}
}
let promise = getArticles();
</script>
<main>
{#await promise}
<p>wait...</p>
{:then articles}
{#each articles.data as article}
<li>
{article.attributes.title}
</li>
{/each}
{:catch error}
<p style="color: red">{error}</p>
{/await}
</main>