Next.js Discord

Discord Forum

Api integration

Unanswered
American black bear posted this in #help-forum
Open in Discord
Avatar
American black bearOP
i have backend in python and i want to integrate api in this ans want to use redux-toolkit as well and i my app directory not src directory. Do i need to create api directory for handing api or do i simple write in client component ?

8 Replies

Avatar
Santhosh Prabhakaran
If you want to create api directory to fetch the data, you can do that. Or else you can simply fetch the data from the server components
Avatar
American black bearOP
@Santhosh Prabhakaran for api directory how to use getStaticPath or getStaticParams ?
Avatar
Santhosh Prabhakaran
You said app directory and why are you using getStaticPath or getStaticParams ?
Those are NextJS 12 versions
Avatar
American black bearOP
could you please let me know how to integrate api . i am using this version of nextjs "next": "13.1.6",
Avatar
Santhosh Prabhakaran
In NextJS 13 versions there is no functions like getStaticPath or getStaticParams
Avatar
American black bearOP
then which is best approach to make api call ?
Avatar
Santhosh Prabhakaran
To get the path and params, you don't need to use these functions. In NextJS 13 ,those things can be get as params in server components. Go through this doc. It will help you
https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating