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

91
Views
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
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!