data returns undefined on Details Page api/snippets/[id].js #762
-
Hello, Here you can find our current status, the branch is called feat/details-view. The router.query in compontents/SnippetDetails.js returns the correct id, but the data is undefined. We'd appreciate your help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Idea:
Make fetcher function Global: https://swr.vercel.app/docs/global-configuration |
Beta Was this translation helpful? Give feedback.
Yes, that is indeed one of the issues.
You can either make the fetcher global, following the link provided by Willy, or you can also add it in the SnippetDetails Component.
You also need to fetch a different route. It should be
There is also another small bug: In your
/pages/api/snippets/[id]/index.js
you are currently checking for therequest.methode
. This should berequest.method
.Hope this already helps