Skip to content

Instantly share code, notes, and snippets.

@tonyspiro
Created July 27, 2020 18:13
Show Gist options
  • Save tonyspiro/d2760fbde9250977663eed55ba1e90f6 to your computer and use it in GitHub Desktop.
Save tonyspiro/d2760fbde9250977663eed55ba1e90f6 to your computer and use it in GitHub Desktop.
app.get('/users', (req, res) => {
if(!req.session.user)
return res.redirect('/?message=unauthorized')
res.locals.user = req.session.user
async.series([
callback => {
Cosmic.getObjectType({ bucket: { slug: config.COSMIC_BUCKET } }, { type_slug: 'users' }, (err, response) => {
res.locals.users = response.objects.all
callback()
})
},
callback => {
Cosmic.getObjects({ bucket: { slug: config.COSMIC_BUCKET } }, (err, response) => {
res.locals.cosmic = response
return res.render('users.html', {
partials
})
})
}
])
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment