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

The store doesn't update in time when using async. #88

Closed
dondish opened this issue Aug 24, 2018 · 1 comment
Closed

The store doesn't update in time when using async. #88

dondish opened this issue Aug 24, 2018 · 1 comment

Comments

@dondish
Copy link

dondish commented Aug 24, 2018

which is weird because I order it to save before sending back data.
if you have any recommendations or fixes feel free.
Code:

/**
 * This will be used to authenticate and retrieve user information
 */
api.post('/user', async (req, res) => {
    id = req.body.id
    password = req.body.password
    rememberMe = req.body.rememberMe
    const data = await auth.login(id, password)
    if (!data) {
        return
    }
    req.session.token = data.id
    if (!rememberMe) {
            req.session.cookie.maxAge = 900000
    }
    req.session.save((err) => {
        if (!err) {
            res.json(data)
        } else {
            res.json({})
        }
    })
})

Database:

Session Table

@dondish dondish closed this as completed Aug 31, 2018
@dondish
Copy link
Author

dondish commented Aug 31, 2018

it was a problem with express-session which I solved

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

No branches or pull requests

1 participant