Is there any way to refresh page in every 10 seconds using SvelteKit? I have to refresh page to get output from endpoint.
Loading data in src/routes/[id].svelte from src/routes/[id].ts.
To refresh an endpoint you can use invalidate in your page route.
import { onDestroy } from "svelte";
import { invalidate } from "$app/navigation";
export your_end_point_prop;
// resfresh your_end_point_prop
const apiInterval = setInterval(async () => {
await invalidate("/your_endpoint");
}, 1000000);
... code to handle your end_point_prop
onDestroy(() => {
clearInterval(apiInterval);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With