Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

142
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda