Skip to content

Instantly share code, notes, and snippets.

@0916dhkim
Created December 29, 2021 02:20
Show Gist options
  • Select an option

  • Save 0916dhkim/21efaea2fd2c95978bf061c318a0d2c3 to your computer and use it in GitHub Desktop.

Select an option

Save 0916dhkim/21efaea2fd2c95978bf061c318a0d2c3 to your computer and use it in GitHub Desktop.
function sendResponse(req, res, component, props = null) {
props = props ?? {};
renderReactTree(res, component, props);
}
router.get('/', function(req, res) {
sendResponse(req, res, Home);
});
router.get('/posts', (req, res) => {
sendResponse(req, res, PostList);
});
router.get('/posts/:id', (req, res) => {
sendResponse(req, res, PostDetails, {id: req.params.id});
});
router.get('/new-post', (req, res) => {
sendResponse(req, res, NewPost);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment