Relative Content

Tag Archive for sveltekit

sveltekit api requests parallel processing

//routes/quotes/+page.js export const load = async ({fetch}) => { // First Fetch Request to Quotes let quotes = []; const fetchQuotes = async () => { const resultQuotes = await fetch(‘https://dummyjson.com/quotes?limit=10’); const quotesData = await resultQuotes.json(); const quotes = quotesData.quotes console.log(“Q” + quotes); return quotes; } // Second Fetch Request to Comments let users = […]

SvelteKit: how to refresh state when opening the same route

I have a top menu bar with links to the different pages on my website. When somebody is on one of those pages and makes some state changes (like filling in a form), then I kind of expect the page to reset to its initial state when the user clicks on the same menu link again. But instead nothing really happens, the state doesn’t reset.

SvelteKit dynamic routing always 404 Not Found

I have a SvetleKit project where I want to add dynamic routes. It is my first big project where I use SvelteKit (it’s way better than React ;). Suppose I have a page on which a lot of objects are displayed in an overview and I want to add a detailed view of each individual object. For the summary I created a /src/routes/overview folder with a +page.svelte for the summary of all objects. For the detailed view, I have made a folder with square brackets around an ID and a +page.svelte, i.e. /src/routes/overview/[objectId]/+page.svelte. But no matter what I do, whenever I navigate to a dynamic route, the content of the +page.svelte in the [objectId] folder is not displayed on the page, but 404 NotFound. I didn’t put anything dynamic in the +page.svelte for testing purposes, only static “HTML”.