Created
July 16, 2014 19:03
-
-
Save redryan/d0ea66829f80c2d63d2d 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('/accounts', function(req, res) { | |
| // if auth has not been set, redirect to index | |
| if (!req.session.accessToken || !req.session.instanceUrl) { res.redirect('/'); } | |
| var query = 'SELECT id, name FROM account LIMIT 10'; | |
| // open connection with client's stored OAuth details | |
| var conn = new jsforce.Connection({ | |
| accessToken: req.session.accessToken, | |
| instanceUrl: req.session.instanceUrl | |
| }); | |
| conn.query(query, function(err, result) { | |
| if (err) { | |
| console.error(err); | |
| res.redirect('/'); | |
| } | |
| res.render('accounts', {title: 'Accounts List’, accounts: result.records}); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment