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

128
Views
why I am getting undefined when I try to access on my property in node js

I have sent data from frontend to backend when I console what type of requests I have gotten I can see the data is showing into the console but when I try to access those properties I got undefined. I have also tried with a query, body but both get undefined when I try to access the property.

enter image description here

Backend code:

   // DELETE SHORT URL
        app.delete('/delete/:shortUrl', async (res, req) => {
            console.log(req);
            console.log(req.params, 'req.params');
        })

Frontend:

 // DELETE 
    const deleteUrl = (id) => {
            fetch(`http://localhost:5000/delete/${id}`, {
                method: 'DELETE'
            }).then(res => res.json())
                .then(data => {
                    console.log(data);
                    if (data.deletedCount) {
                        alert('Order Deleted')
                        // const remainingOrders = orders.filter(order => order._id !== id)
                        // setOrders(remainingOrders)
                    }

                })
                .finally(() => setLoadings(false))
    
    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Based on the Express documentation, the route callback's parameters (req & res) are reversed, so you should have:

app.delete('/delete/:shortUrl', (req, res) => {
  console.log(req);
  console.log(req.params, 'req.params');
})
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!