Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

151
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda