In Nuxt 3, there is a dedicated server
folder containing an api
subfolder. Why should we utilize this when we already have API endpoints built with a server-side programming language like Laravel? Are they linked in any way?
For instance, consider these Laravel-created endpoints:
http://www.example.com/product
http://www.example.com/product/1
We can fetch data from these endpoints using methods like useFetch
or $fetch
. Is it necessary to make use of the server/api
folder in such cases?
For example, within the server
directory, we have files and folders structured as follows:
server/api/product/index.get.ts
server/api/product/[productId]/index.get.ts
Can you clarify whether these components are interconnected or not? When is it appropriate to leverage the server
folder?