Use fetch to pass variable in rails

I am creating an app in Rails with Reactjs. I want to pass the value of input field to the controller as a variable so that I can use that variable in def create . How can I do that with fetch?

I’m not sure you’d need to use fetch for this. What you’d need to do in your React component is craft an appropriately-shaped REST request. If you are updating a Widget with id=42, you want a PATCH or PUT that sends an array of parameters that look like: widget[color]=red&widget[style]=pro to /widgets/42.