You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Better developer experience while debugging complicated apps with calls to different server actions
Being able to test endpoints in isolation
Non-Goals
No response
Background
The Network tab in browsers' DevTools provide a convenient place to monitor and debug client-server interactions. In a legacy REST API, one can easily know which server function is being called by checking the URL.
After switching to Server Actions in a web application with lots of server actions being called from different client components its very difficult to distinguish which server action is being called as all you have is a random token sent as a request header (next-action ).
Also if you choose to test these endpoints in isolation from the calling client - as after all, Server Actions are public facing REST APIs listening for POST requests - there is no easy way to find the token assigned to each server action.
Proposal
const addAction = (a, b) => a + b
addAction.actionName = 'add-action' // <-- use this string instead of generated token
export default addAction
Now we can:
Check the request header and know which action is this in the Network tab.
Send test requests targeted at specific action via network tools like Postman for testing / debugging purposes.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
No response
Background
The Network tab in browsers' DevTools provide a convenient place to monitor and debug client-server interactions. In a legacy REST API, one can easily know which server function is being called by checking the URL.
After switching to Server Actions in a web application with lots of server actions being called from different client components its very difficult to distinguish which server action is being called as all you have is a random token sent as a request header (
next-action
).Also if you choose to test these endpoints in isolation from the calling client - as after all, Server Actions are public facing REST APIs listening for POST requests - there is no easy way to find the token assigned to each server action.
Proposal
Now we can:
Beta Was this translation helpful? Give feedback.
All reactions