Allow ClientAction to change the request which will be sent to the server #11285
Closed
rubber-duck-software
started this conversation in
Proposals
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Admittedly this has the chance to be abused but there are a few scenarios where modifying the request sent to the server might be handy.
For me, I'm trying to save card details on form submit (using stripe) and then send the card-id in the formData to the serverAction.
Right now, this kind of "right before you submit" processing has to be handled with an event.preventDefault() on form submit, which is a shame. Client action provides the perfect place to perform this kind of processing and then hand the request off to the server.
I propose add request as an optional parameter to
serverAction
. If no request is passed, the server action is called with the same request as client action. If a request is passed, that request is sent to the server instead.The usage would look something like
Beta Was this translation helpful? Give feedback.
All reactions