Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Is it possible to #await with onMount together

$
0
0

I'd like to use convenient #await Svelte helper when loading data with fetch().

However, I noticed a warning at onMount tutorial [1]:

It's recommended to put the fetch in onMount rather than at the top level of the <script> because of server-side rendering (SSR).

I don't need SSR, but wanted to try it out. Hovewer, onMount() doesn't return a Promise, and I cannot create a Promise that resolves with onMount().

Is it possible to use onMount() together with #await?

[1] https://svelte.dev/tutorial/onmount


Viewing all articles
Browse latest Browse all 1541

Trending Articles