Reusing FormData between clientAction and action #9907
-
Hello, I am using Firebase for my auth / user management and have a scenario when a user may choose to change their password which can be browser or server side (I've chosen server side). Sometimes, Firebase will require the user to sign in again. The sign in method is browser only. When I try to unpack the request.formData twice (once in clientAction and again in action) I get the following error:
My naive view is that I should be able to access formData at least once in each action. Is there a pattern for being able to do this?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I think that when Remix calls your Try using This clones the request in the https://developer.mozilla.org/en-US/docs/Web/API/Request/clone |
Beta Was this translation helpful? Give feedback.
I think that when Remix calls your
serverAction
, it's also processing the request again, so that's why you get the error.Try using
await request.clone().formData()
This clones the request in the
clientLoader
so you won't get the error.https://developer.mozilla.org/en-US/docs/Web/API/Request/clone