Created
September 7, 2017 00:11
-
-
Save keithnorm/1d4bec394bbacc7ef1300baa18877bfa to your computer and use it in GitHub Desktop.
This file contains 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
// on the server | |
import { renderToStaticMarkup } from 'react-dom/server'; | |
import MongoClient from 'mongodb'; | |
app.get('*', (req, res) => { | |
var url = 'mongodb://localhost:27017/todo-app'; | |
MongoClient.connect(url, function(err, db) { | |
res.status(200).render('layout', { | |
locals: { | |
body: renderToStaticMarkup(<TodoApp db={db}/>), | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment