Skip to content

When to use Fetch in RequestEvent #13477

Answered by brunnerh
karchung0930 asked this question in Q&A
Discussion options

You must be logged in to vote

See the note in the fetch APIs documentation:

A special version of fetch is available in load functions, server hooks and API routes for invoking endpoints directly during server-side rendering, without making an HTTP call, while preserving credentials. (To make credentialled fetches in server-side code outside load, you must explicitly pass cookie and/or authorization headers.) It also allows you to make relative requests, whereas server-side fetch normally requires a fully qualified URL.

So it's available pretty much everywhere and when the code runs on the server, it does not even involve a network call.

There is also some more documentation in the types section of the docs, see e.g. t…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by karchung0930
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants