Created
February 22, 2018 20:19
-
-
Save onefriendaday/a29c917a05e1bdf8751ef68ca391ea9b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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