Skip to content

Instantly share code, notes, and snippets.

@tonyspiro
Created July 27, 2020 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonyspiro/36d4a91f4e835f1817dea0509513e519 to your computer and use it in GitHub Desktop.
Save tonyspiro/36d4a91f4e835f1817dea0509513e519 to your computer and use it in GitHub Desktop.
// home.js
import Cosmic from 'cosmicjs'
module.exports = (app, config, partials) => {
app.get('/', (req, res) => {
Cosmic.getObjects({ bucket: { slug: config.COSMIC_BUCKET } }, (err, response) => {
res.locals.cosmic = response
if (req.query.message === 'unauthorized')
res.locals.unauthorized_message = true
return res.render('index.html', {
partials
})
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment