Open theodorosploumis opened 1 year ago
I see what you mean. We're actually doing same for most of our sites: using a proxy API route for making getResource
and getResourceCollection
calls.
The reason we did not ship this in the package and rather leave it to the dev for implementation is we want the package to be unopinionated and not hardcode the routes.
Maybe we could cover this in a guide instead? The implementation is quite simple.
What do you think?
(Note: this might change in the upcoming release of Next.js which will allow component-level data fetching)
...component-level data fetching
That's great. Do you have any link for this discussion?
I believe server components in the app router will make this possible. When the docs for this are completed we can link them back here, and close this issue.
As far as I can understand, all the
next-drupal
methods are async and return Promises. This disallows using them inside React components unless you useuseEffect
or similar hooks.Do you believe is is a good idea to create a proxy like API route to handle the async functions? I mean create this inside the
next-drupal
starter kit.E.g. for method
getResource()
we could have an API route on/api/next-drupal/getResource
asking for the same parameters with the original function (https://next-drupal.org/docs/reference/getresource).What are your thoughts?