Ask about express session

Hi! is it possible to store req.session from app.post? im using express, and redis

app.post("/callback", (req, res) => {
  console.log(req.session); //this
  Promise.all(req.body.events.map(handleEvent))
    .then(result => res.json(result))
    .catch(err => {
      console.error(err);
    });
});

function handleEvent(event) {
  //is it possible to access req.session here?
}

that my code

I don’t think so because req.session is a request variable as the parameter in the post request. Assigning it to another variable to be used in a function might not also work because variables declared in the post request are of a higher scope and therefore cannot be used outside the POST request.

I’m also facing a similar issue where I’m trying to get an array out of a fetch request to an API, which I need to use in another function :frowning:

2 Likes