N
Nuxt5mo ago
Gendarme

API route errors

Have I structured this incorrectly? I have a GET endpoint at /api/department and also e.g. a DELETE endpoint at /api/department/:id. Calling these endpoints with $fetch. I'm getting the error message that Type '"DELETE"' is not assignable to type '"get" | "GET" | undefined', which is due to the intellisense not seeing the catch-all routes.
No description
4 Replies
Gendarme
GendarmeOP5mo ago
I'm just trying to build a normal REST API structure. Nothing fancy at all.
brunomgmateus
brunomgmateus5mo ago
seems correct. But shouldn't it be [id].delete.ts?
brunomgmateus
brunomgmateus5mo ago
Nuxt
server/ · Nuxt
The server/ directory is used to register API and server handlers to your application.
Gendarme
GendarmeOP5mo ago
Hmm But they do [...slug] Thought it would be the same, but maybe not Thanks! I went straight to #catch-all-route and missed the earlier section about named routes.
Want results from more Discord servers?
Add your server