Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added: Promise return type for req.session.save() function #701

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Added: Promise return type for req.session.save() function #701

wants to merge 5 commits into from

Conversation

NrI3
Copy link

@NrI3 NrI3 commented Oct 11, 2019

No description provided.

Add Promise type object for use as Promise return in req.session.save()
Now we can use req.session.save() function as promise example

await req.session.save()
    .then(()=>{
        console.log('saved')
    })
    .catch(()=>{
        console.log('error')
    })
@salisbury-espinosa
Copy link

ping

@sgnl
Copy link

sgnl commented Jun 11, 2022

What could be done to get this PR integrated?

@twelve17
Copy link

One workaround is to add the promisified function via middleware:

import { promisify } from 'util';

...

// make "saveAsync" available to other routes
// could also be done via app.use()
router.use((req, _res, next) => {
    req.session.saveAsync = promisify(req.session.save.bind(req.session));
    next();
  });

...

router.post('/xyz', async (req, res, next)  => {
   await req.session.saveAsync();
   
   // do more stuff
});
  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants