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

118
Views
How to pass some information from one get/post to another get/post

lets say i have code like this where i have post on loginuser. This code should work normally but i want to ask you, if there is way of how to pass some information from this post to another get or post. For example my next get would be like this:

app.get("/somepage", function(request,response){
 if(user is logged in)
response.render("page");
 else
response.render("login);
}

And i want to pass something from my post loginuser so i can check if user is loggedin so he can visit this somepage or if he is not he will be redirected to login page.

app.post("/loginuser", async function(request, response){
try {
var email = request.body.email;
var password = request.body.password;

if(!email || !password){
  return response.status(400).render("login",{
    message: "Provide an email and password"
  })
}

db.query("SELECT * FROM users WHERE email = ?", [email], async function(error,results){
  if(!results || !(await bcrypt.compare(password, results[0].password))){
    return response.status(401).render("login",{
      message: "Email or password incorrect"
    })
  }
  else{
    const id = results[0].id;
    const token = jwt.sign({id:id}, process.env.JWT_SECRET,{
      expiresIn: process.env.JWT_EXPIRES_IN
    })
    const cookieOptions = {
      expires: new Date(
        Date.now() + process.env.JWT_COOKIE_EXPIRES * 24 * 60 * 60 * 1000
      ),
      httpOnly: true
    }
    response.cookie("jwt", token, cookieOptions);
    response.render("home");
  }
})

} catch (error) {
console.log(error);}})
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!