Using javascript to create an object in a rails API

To create an object in a rails API using javascript in the frontend we first need to set up our backend. Make sure you have your controller setup(also your models, tables, database …etc) so that it has the ability to create it on the rails side(make sure you are permitting the values you need). In your controller be sure to add ‘render json: example’ if you want to get the new object you created back in the response.