Next.js Discord

Discord Forum

Server Actions, and services folder

Unanswered
Yacare Caiman posted this in #help-forum
Open in Discord
Yacare CaimanOP
Hello, I have a question, I am using the services folder to make calls to the api of next js, are they necessary? The problem is that I am not using the server actions theme to 100
It seems to me that it is unnecessary and a custom hook could be created, to improve further

7 Replies

I would just use server actions. Why do you need an API to call the API?
Also the GET on the url endpoint looks funny IMO
Yacare CaimanOP
mmm, why you say api to call the api? We use the services, since when we use server client, we cannot use the endpoints there, but I don't understand what you are saying with api sorry
Instead of using the services folder, I would use a server action, which is a modularized function.
Yacare CaimanOP
aaa I understand, you say that the api folder is necessary because I have an api out now lol
I might be understanding it wrong, if so I'm sorry.

What I mean is that you have an API: V2_MAIN_SERVICE_URL.
Why dont you call fetch directly to that API, instead of creating another one "order-byID" ?
Yacare CaimanOP
mmm because the env doesn't work for me, since it was a use client, but I could use a use server and it should work correctly, and someone was to cover the data