We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No response
Hydrogen
2024.1.1
2.4.1
For example, I have a button in a component that uses useFetcher() for send data to locale cart route
<button type='submit' onClick={(e) => { fetcher.submit( { action: 'ActionTest', inputs: { test: ['test1', 'test2'], }, }, { action: '/cart', method: 'POST', }, ); }} > <span className='cart-btn-text'>Send data</span> </button>;
in ($locale).cart.tsx i have this action
($locale).cart.tsx
export async function action({ request, context }: ActionFunctionArgs) { const { cart } = context; const formData = await request.formData(); const { action, inputs } = CartForm.getFormInput(formData); console.log('inputs', inputs); console.log('action', action); invariant(action, 'No cartAction defined'); // .... // code to update the shopify cart component (not important) // .... return json( .... ); }
The logs are this:
inputs Object { action: ActionTest, inputs: [object Object] } action undefined
I think it may be an error in how CartForm.getFormInput() handles the data.
This is just an example but the problem does not allow me integrate useFetcher with Shopify Hydrogen Cart.
I see the official documentation but the result is the same
https://shopify.dev/docs/api/hydrogen/2023-07/components/cartform#example-cartform-with-fetcher
Logs
inputs Object { lines: Array(2), } action LinesAdd
This is how data arrives using component
The text was updated successfully, but these errors were encountered:
Hey @porrodv
Try something like this:
fetcher.submit( { cartFormInput: JSON.stringify({ action: 'ActionTest', inputs: { test: ['test1', 'test2'], }, }), }, {method: 'POST', action: '/cart'}, );
Sorry, something went wrong.
Looks like this is resolved
No branches or pull requests
What is the location of your example repository?
No response
Which package or tool is having this issue?
Hydrogen
What version of that package or tool are you using?
2024.1.1
What version of Remix are you using?
2.4.1
Steps to Reproduce
For example, I have a button in a component that uses useFetcher() for send data to locale cart route
in
($locale).cart.tsx
i have this actionThe logs are this:
I think it may be an error in how CartForm.getFormInput() handles the data.
This is just an example but the problem does not allow me integrate useFetcher with Shopify Hydrogen Cart.
I see the official documentation but the result is the same
https://shopify.dev/docs/api/hydrogen/2023-07/components/cartform#example-cartform-with-fetcher
Expected Behavior
Logs
This is how data arrives using component
Actual Behavior
Logs
The text was updated successfully, but these errors were encountered: