Skip to content
Advertisement

Insert into SQL database from React front end

Im trying to insert some data into a SQL table but Im getting nothing from the front or back end I have tried console.log at various intervals but I cant seem to get data from either side.

For reference I have table called products with three columns id, name, image Im trying to insert both name and image with a button click. Additionally im trying to delete data thats been inserted and that also does nothing.

I have already achieved this with one table but that table only has one column.

Heres the front end

And the back end

Advertisement

Answer

You have a problem in your frontend code, the setName and setSrc are done improperly:

Here’s how it should be:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement