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

143
Views
Updating password using 'PUT' method

can someone help me to understand how to use the query function created to update a password in my database?

here is the query function in question

async function updatePassword(req, res) {
return db.none('UPDATE user_account SET password = $1 WHERE email = $2',
        [req.body.password, req.body.email])
    .then(function () {
        res.status(200)
            .json({
                status: 'success',
                message: 'Updated user'
            });
    })
    .catch(error => {
        console.log(error)
    });

}

here is what I tried to do with fetch method put

resetPassword(){
            fetch('http://url/example', {
                    method: 'PUT',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify({
                        email: this.email,
                        password: this.passwordReset,
                        
                    }),
            })
        // Converting to JSON
        .then(response => response.json())
        // Displaying results to console
        .then(json => console.log(json));       
        },

no error "{status: 'success', message: 'Updated user'}"

but nothing has changed in my database

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

0

'UPDATE user_account SET password = $1 WHERE email = $2' you pass the both req.params and req.body so in your case req.params.email pass the execution and success for it and i think this is the bad idea using both in one.

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!