Skip to content

Instantly share code, notes, and snippets.

@onefriendaday
Created February 22, 2018 20:19
Show Gist options
  • Save onefriendaday/a29c917a05e1bdf8751ef68ca391ea9b to your computer and use it in GitHub Desktop.
Save onefriendaday/a29c917a05e1bdf8751ef68ca391ea9b to your computer and use it in GitHub Desktop.
app.get('/*', function(req, res) {
var path = url.parse(req.url).pathname;
path = path == '/' ? 'home' : path
Storyblok
.get(`stories/global`, {
version: req.query._storyblok ? 'draft': 'published'
})
.then((response) => {
Storyblok
.get(`stories/${path}`, {
version: req.query._storyblok ? 'draft': 'published'
})
.then((detail_response) => {
res.render('index', {
story: detail_response.body.story,
global: response.body.story
});
})
.catch((error) => {
res.send(error);
});
})
.catch((error) => {
res.send(error);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment