Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
Endpoint URL not found in axios PUT endpoint

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: enter image description here

The server side of the endpoint:

app.put('/merch/:name', function (req, res) {
  const { name } = req.params;
  const { Quantity } = req.body;

  connection.getConnection(function (err, connection) {
     if(err) {
         console.log(err)
         return
     }

     connection.query(`UPDATE merch SET Quantity = ${Quantity} WHERE name = ${name}`, function (error, results, fields) {
       
      if (error)
      {
        throw error;
      }
    });
   });
});

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?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to define the route like below:

// this will match route like /merch/CrossBag or /merch/Blanket
app.put('/merch/:name', function (req, res) {
  const {name = '' } = req.params; 
  connection.getConnection(function (err, connection) {
     if(err) {
         console.log(err)
         return
     }
   });
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!