Created
May 22, 2023 14:41
-
-
Save jeffdonthemic/09309b6f87f6b9b26632f3ff65828e55 to your computer and use it in GitHub Desktop.
sfdx / jsforce
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
const jsforce = require('jsforce'); | |
const { exec } = require('child_process'); | |
exec("sfdx org display --json", (error, stdout, stderr) => { | |
let org = JSON.parse(stdout); | |
console.log('================='); | |
console.log(org.result.username); | |
console.log(org.result.instanceUrl); | |
console.log('================='); | |
var conn = new jsforce.Connection({ | |
instanceUrl : org.result.instanceUrl, | |
accessToken : org.result.accessToken | |
}); | |
conn.query("SELECT Id, Name FROM User", function(err, res) { | |
if (err) { return console.error(err); } | |
console.log(res); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment