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

86
Vistas
how to insert into database and check if it is already in the database before successful google log in

I want to know how to take the coupon input and check if it is already in the coupons database before successful google log in. (If the coupon is in the coupons database then log in successfully).

const responseGoogle = async (response) => {
        console.log(response)
        try {
            const req = await axios.post(`${process.env.REACT_APP_BASE_URL}/api/v1/login/google/googlelogin`,
                { tokenId: response.tokenId }, { withCredentials: true }
            )
            if (req.status === 200) {
                localStorage.setItem('loginstatus', 'true')
                localStorage.setItem('userprofile', JSON.stringify(response.profileObj))
                history.push('/welcome')
            }
            else {
                alert('err')
            }
        }
        catch (e) {
            (e.response.status === 400 && e.response.data.reason === 'not_domain') ?
                alert('Your email domain is not valid') :
                alert('An error occurred')
        }
    }
return(
<>
<GoogleLogin
                clientId={process.env.REACT_APP_GOOGLE_ID}
                render={renderProps => (
                    <Button onClick={renderProps.onClick} disableElevation disabled={renderProps.disabled} variant="outlined" color="default">
                        <img src={logo} alt="Google Logo" className="login_logo_comp" />  Sign in with Google
                    </Button>
                )}
                buttonText="Login"
                onSuccess={responseGoogle}
                onFailure={failed}
                cookiePolicy={'single_host_origin'}
            />
</>
)

Would adding prompt to take the coupon input work? how to do this? and it should be before user enter google information or after? what other ways to do that?

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