Next.js Discord

Discord Forum

Is there a way that I can intercept a server actions or any API call?

Unanswered
Seppala Siberian Sleddog posted this in #help-forum
Open in Discord
Seppala Siberian SleddogOP
I have a use case where I want to intercept each API call and show a snackbar on each successful message globally, I know that I can implement it using axios for example but that would mean that I would sacrifice the use of server actions which has a lot of security benefits, because the API call has to be done to an endpoint using axios so, how can I achieve something similiar wihtout implementing it to each API call?

2 Replies

"server actions which has a lot of security benefits"
can you elaborate on what your thinking because its just as unsecure as normal api function
@riský "server actions which has a lot of security benefits" can you elaborate on what your thinking because its just as unsecure as normal api function
Seppala Siberian SleddogOP
because I can access server side information without exposing anything to the client, instead of creating the API handler itself it might be as secure as a normal API handler but it's a lot easier to use, and it saves much more time as well.