When pressing a button, my app is suppose to subtract 1 from the current Quantity in the database where the name of the item is “CrossBag”
My PUT endpoint on the client:
confirm = () => {
axios.put(`http://localhost:5000/merch/CrossBag`, {
Quantity: this.state.merchInfo[0].Quantity - 1,
});
};
The structure of my table merch where Name is the primary key:
The server side of the endpoint:
app.put('/merch', function (req, res) {
connection.getConnection(function (err, connection) {
if(err)
{
console.log(err)
return
}
});
});
When I press the button though it states:
PUT http://localhost:5000/merch/CrossBag 404 (Not Found)
I’m a bit confused on how to update specifically that row’s Quantity. I read that you need some kind of ID to specify which row to change, so I made that ID my Primary Key (Name).
Can anyone provide me any guidance?