Skip to content

Instantly share code, notes, and snippets.

@redryan
Created July 16, 2014 19:03
Show Gist options
  • Select an option

  • Save redryan/d0ea66829f80c2d63d2d to your computer and use it in GitHub Desktop.

Select an option

Save redryan/d0ea66829f80c2d63d2d to your computer and use it in GitHub Desktop.
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