Next.js Discord

Discord Forum

Calling Server functions from server component is not working

Unanswered
Asian black bear posted this in #help-forum
Open in Discord
Asian black bearOP
When we get 401 status code i want to call the fetchNewRefreshApi function which is in server and is handling manipulating cookies especially from the server component but this is not working

Any ideas on how to achieve it. I can only achieve it from the client side by calling server function to manipulate cookies but i want to achieve it from the server side

1 Reply

Asian black bear
The usual way is to extract whatever logic you are using in the api that you want to call from the server component into a separate file, and instead import it directly into the server component.