Must I always use RequestHandler to make Endpoint with Sveltekit?

Viewed 209

I am making some Todo website with this Video svelte fullstack app and in this Video Teacher uses RequestHandler to make Endpoint..

But in this sveltekit documents they tell me use just normal function like that body-parsing

So My Questions is "must i use RequestHandler or Could i use normal Function?"

1 Answers

Koen seems to have got the idea. I believe you're confused about the TypeScript type that was used in the video.

export const get: RequestHandler = () => {

is the TypeScript equivalent of

/** @type {import('@sveltejs/kit').RequestHandler} */
export const get = () => {

Which is the type safe Javascript equivalent.

Related