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

347
Vistas
Nodejs: Why is the page reloading when I upload a JSON file?

When I am updating a .json file (fs module) in nodejs server, the webpage is getting reloaded.

Client-side:
when the button is clicked, info is transferred to the server for processing, this is done using socket.io

registerBtn.click(event => {
    event.preventDefault()

    if (regUsername.val().length <= 2 || regPasssword.val().length < 8) {
        _showLoginRegisterError('Fill in all fields as indicated', 'register')
    } else {
        let username = regUsername.val()
        let mail = registerMail.val()
        let password = regPasssword.val()
        socket.emit('register', { username, password, mail })
    }
})

Server-side:

socket.on('register', data => { // when users registers

//checking if all the details of the user are valid
        
                        if (!data[0]) socket.emit('sign-log-error', 'register', 'Invalid mail')
                        else {
                            const validation = {}
                            validation[mail] = [username, password, data[1]]
                            jdb.assignI('other', 'validating', validation) //-> this is reloading the webpage
                            socket.emit('otp-sent-verify', mail)
                        }
                    })
                }
                else socket.emit('sign-log-error', 'register', 'Invalid mail')

                // now if user is verified, then add user to db
            }
        }
    })
});

I am sending updating a .json file that stores name of the users that to be verified. But when I am updating the json file, the page is getting reloaded and is disturbing the process.

jdb.assignI() is a function that just assigns some dataa to JSON files

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