Skip to content
Advertisement

Reactjs- Edit form not updating the database table

I am trying to create an edit form that will enable me update data in a table. When I click on the ‘edit’ button on my table it correctly redirects me to the edit form and data is also being correctly filled into the respective fields of the form, no issue there.

The only issue I am facing is that when I click on ‘edit’ on the form it does not update anything. I have used then same format for other forms and it works correctly but in this particular form I am having this issue.

Maybe there is something I may have done wrong and am unable to detect it so if you could help me see what I have done wrong that would be a real timesaver. I have looked at it for 2 days but am unable to see what I have done wrong.

editticket.js:

JavaScript

backend code from index.js:

JavaScript

Even if the mistake may be stupid or something please help me out as I have tried to see and scrutinized it hard but cannot figure out what I did wrong.

Advertisement

Answer

I realized that I had not allowed PUT request in my backend under cors: This is the edit:

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