Replies: 1 comment
-
This seems to be partially solved with |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way to generate urls based on "known routes" in the app, e.g. with a function similar to Flask's and Rails'
url_for
?For example, here is the problem I'm trying to solve
routes/api/todo/+server.ts
route+page.svelte
page, likefetch('/api/todo', /* more params */)
routes/api/todos/+server.ts
If I could instead do
fetch(urlFor('api/todo'))
, then rename errors would be caught during a build for production, since it wouldn't match a known route in Sveltekit.As a bonus, it would be slightly easier to construct urls like
/api/todo/[id]
e.g. likeurlFor('/api/todo', { id: 1234 })
, and perhaps this could even be typesafe (if using TypeScript)Thank you.
Beta Was this translation helpful? Give feedback.
All reactions