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

144
Views
cannot retrive Data from fetch

Frontend snippet

const dateObj = { Date: date }
    const raw = JSON.stringify(dateObj)
    console.log(raw);
 const fetchData = async () => {
      const response = await fetch('http://localhost:8000/foodsSend', {
        method: 'PATCH',
        headers: myHeaders,
        body: raw

      })
      const datasss = await response.json()
      console.log(datasss);
    }


backend Snippet

router.patch('/foodsSend', auth, async (req, res) => {

    console.log(req.body.Date)


    try {
        await req.user.populate({
            path:'foods',
            match:{
                date:req.body.Date
            }
        }).execPopulate()
        console.log(req.user.foods)
        res.send(req.user.foods)
     
    } catch (e) {
        res.status(500).send()
    }
})

when i make the same request from Postman, i get the array of data back, but it is not working for fetch in browser. I also console logged the date, In both the case(via browser or postman) the date is same 04/14/2020 and of type string. still only postman returns the data not the fetch api. please help

about 4 years ago · Juan Pablo Isaza
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!