Data fetching API pages from server-side without using fetch. #15213
Unanswered
misterjohannesson
asked this question in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi guys.
I have created this little wrapper for fetching API pages server-side without actually fetching.
I have achieved this task by creating a simple NextApiRequest and NextApiResponse from the NextPageContext available in getInitialProps and then proceeding to execute the code.
It isn't all feature complete, but I was wondering if anyone has done something similar and know of some caveats or issues? For now, I'll continue to build this out a bit further and report back to my gist with updates.
It ends up looking this in my getInitialProps/getServerSideProps
https://gist.github.com/objmj-itminds/af465e6f3f904675be48cc620b41a604
Beta Was this translation helpful? Give feedback.
All reactions